用JAVASCRIPT幫我寫個(gè)計(jì)數(shù)器
更新時(shí)間:2007年02月23日 00:00:00 作者:
你們能用JAVASCRIPT幫我寫個(gè)計(jì)數(shù)器嗎?要帶文本的那種,我在ASP那里要用呀?拜托..........
我自己寫了一個(gè),是不帶文本的,誰能幫我彌補(bǔ)一下呢?
<%@ Language=Jscript %>
<%
Application.Lock();
Application("Counter") = parseInt(Application("Counter")) + 1;
Application.UnLock();
%>
我知道要用到<%
var path = Server.MapPath("test.txt");
var MyFileObject = Server.CreateObject("Scripting.FileSystemObject");
var MyTextFile = MyFileObject.CreateTextFile(path);
MyTextFile.WriteLine("");
MyTextFile.Close();
%>這些命令,可具體怎么寫呢?
給你一個(gè)最全的吧:
<script language = "vbscript" runat = "server">
sub application_onstart
'取的計(jì)數(shù)文件的真實(shí)路徑
countfile=server.mappath("count.txt")
'創(chuàng)建文件系統(tǒng)對(duì)象實(shí)例
set myfso = server.createobject("scripting.filesystemobject")
'若計(jì)數(shù)文件不存在
if not myfso.fileexists(countfile) then
'創(chuàng)建該文件及取得textstream對(duì)象實(shí)例
set mytextstream = myfso.createtextfile(countfile, True)
application.lock
application("online") = 0
application("counter") = 0
application.unlock
'將計(jì)數(shù)值寫入文件
mytextstream.writeline(cstr(application("counter")))
else
'以只讀的方式打開
set mytextstream = myfso.opentextfile(countfile,1,false)
'讀一行,并將值賦給計(jì)數(shù)變量
application("counter") = mytextstream.readline
end if
mytextstream.close
set myfso = nothing
end sub
sub session_onstart
session.timeout = 1
countfile = server.mappath("count.txt")
set myfso = server.createobject("scripting.filesystemobject")
application.lock
application("online") = application("online")+1
application("counter") = application("counter")+1
application.unlock
'以寫方式打開文件
set mytextstream = myfso.opentextfile(countfile,2,false)
'以寫行的方式將數(shù)據(jù)寫入文件
mytextstream.writeline(cstr(application("counter")))
mytextstream.close
set myfso = nothing
end sub
sub session_onend
application.lock
application("online") = application("online")-1
application.unlock
end sub
</script>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>計(jì)數(shù)器例子</title>
</head>
<body>
<div align="center">您是本站第<font color="#FF0000"><%=application("counter")%></font>位貴賓!
</div>
</body>
</html>
我自己寫了一個(gè),是不帶文本的,誰能幫我彌補(bǔ)一下呢?
<%@ Language=Jscript %>
<%
Application.Lock();
Application("Counter") = parseInt(Application("Counter")) + 1;
Application.UnLock();
%>
我知道要用到<%
var path = Server.MapPath("test.txt");
var MyFileObject = Server.CreateObject("Scripting.FileSystemObject");
var MyTextFile = MyFileObject.CreateTextFile(path);
MyTextFile.WriteLine("");
MyTextFile.Close();
%>這些命令,可具體怎么寫呢?
復(fù)制代碼 代碼如下:
給你一個(gè)最全的吧:
<script language = "vbscript" runat = "server">
sub application_onstart
'取的計(jì)數(shù)文件的真實(shí)路徑
countfile=server.mappath("count.txt")
'創(chuàng)建文件系統(tǒng)對(duì)象實(shí)例
set myfso = server.createobject("scripting.filesystemobject")
'若計(jì)數(shù)文件不存在
if not myfso.fileexists(countfile) then
'創(chuàng)建該文件及取得textstream對(duì)象實(shí)例
set mytextstream = myfso.createtextfile(countfile, True)
application.lock
application("online") = 0
application("counter") = 0
application.unlock
'將計(jì)數(shù)值寫入文件
mytextstream.writeline(cstr(application("counter")))
else
'以只讀的方式打開
set mytextstream = myfso.opentextfile(countfile,1,false)
'讀一行,并將值賦給計(jì)數(shù)變量
application("counter") = mytextstream.readline
end if
mytextstream.close
set myfso = nothing
end sub
sub session_onstart
session.timeout = 1
countfile = server.mappath("count.txt")
set myfso = server.createobject("scripting.filesystemobject")
application.lock
application("online") = application("online")+1
application("counter") = application("counter")+1
application.unlock
'以寫方式打開文件
set mytextstream = myfso.opentextfile(countfile,2,false)
'以寫行的方式將數(shù)據(jù)寫入文件
mytextstream.writeline(cstr(application("counter")))
mytextstream.close
set myfso = nothing
end sub
sub session_onend
application.lock
application("online") = application("online")-1
application.unlock
end sub
</script>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>計(jì)數(shù)器例子</title>
</head>
<body>
<div align="center">您是本站第<font color="#FF0000"><%=application("counter")%></font>位貴賓!
</div>
</body>
</html>
您可能感興趣的文章:
- 一個(gè)簡單的網(wǎng)站訪問JS計(jì)數(shù)器 刷新1次加1次訪問
- js計(jì)數(shù)器代碼
- JavaScript實(shí)現(xiàn)計(jì)數(shù)器基礎(chǔ)方法
- 使用JavaScript制作一個(gè)簡單的計(jì)數(shù)器的方法
- jsp網(wǎng)頁計(jì)數(shù)器實(shí)現(xiàn)示例
- javascript下計(jì)數(shù)器每秒自動(dòng)加1
- 一個(gè)可以防止刷新的JSP計(jì)數(shù)器
- jsp計(jì)數(shù)器制作
- jsp計(jì)數(shù)器代碼
- 原生js實(shí)現(xiàn)寬度計(jì)數(shù)器
相關(guān)文章
Asp DatePart 函數(shù)的語法詳解(用于計(jì)算日期并返回指定的時(shí)間間隔)
ASP(VBScript) 參考手冊(cè)中,已經(jīng)對(duì) DatePart 作了說明,但其對(duì)第一個(gè)參數(shù)的解釋太過書面,造成令人誤解,現(xiàn)重新解釋一下2012-07-07后臺(tái)管理登錄篇-asp設(shè)計(jì)與數(shù)據(jù)庫
后臺(tái)管理登錄篇-asp設(shè)計(jì)與數(shù)據(jù)庫...2007-02-02ASP基礎(chǔ)知識(shí)Command對(duì)象講解
這篇文章主要介紹了ASP中Command對(duì)象,是ASP入門教程,感興趣的小伙伴們可以參考一下2015-09-09javascript asp教程服務(wù)器對(duì)象
javascript asp教程服務(wù)器對(duì)象...2007-03-03ASP 中 DateDiff 函數(shù)詳解 主要實(shí)現(xiàn)兩日期加減操作
ASP 中 DateDiff 函數(shù)詳解 主要實(shí)現(xiàn)兩日期加減操作...2007-11-11asp Fix、Int、Round、CInt函數(shù)使用說明
Fix(number) 和 Int(number) 都是返回?cái)?shù)字的整數(shù)部分,Round(number, numdecimalplaces),第二個(gè)參數(shù)表示從小數(shù)點(diǎn)右邊第幾位開始實(shí)行四舍五入,可以省略,默認(rèn)是0,即四舍五入返回整數(shù)2011-05-05ASP文章系統(tǒng)解決方案實(shí)現(xiàn)上一頁下一頁
ASP文章系統(tǒng)解決方案實(shí)現(xiàn)上一頁下一頁...2007-01-01