Can you use JavaScript to write a counter for me? The one with the text, I want to use it in ASP? Please ...
I have written one, is not with the text, who can help me to make up for it?
<%@ Language=jscript%>
<%
Application.Lock ();
Application ("Counter") = parseint (Application ("Counter")) + 1;
Application.UnLock ();
%>
I know I'm going to use <%.
var path = Server.MapPath ("test.txt");
var myfileobject = Server.CreateObject ("Scripting.FileSystemObject");
var mytextfile = myfileobject.createtextfile (path);
Mytextfile.writeline ("");
Mytextfile.close ();
%> These commands, how can you write them specifically?
Copy Code code as follows:
Give you one of the most complete bar:
<script language = "vbscript" runat = "server" >
Sub Application_OnStart
' Take the true path of the count file
Countfile=server.mappath ("Count.txt")
' Create a file system object instance
Set myfso = Server.CreateObject ("Scripting.FileSystemObject")
' If the count file does not exist
If not myfso.fileexists (Countfile) Then
' Create the file and get the TextStream object instance
Set mytextstream = Myfso.createtextfile (Countfile, True)
Application.Lock
Application ("online") = 0
Application ("counter") = 0
Application.UnLock
' Writes the count value to the file
Mytextstream.writeline (CStr (Application ("Counter"))
Else
' Open in read-only mode '
Set mytextstream = Myfso.opentextfile (countfile,1,false)
' Read a line and assign the value to the count variable
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
' Open file as write '
Set mytextstream = Myfso.opentextfile (countfile,2,false)
' Writes the data to the file in a write-line way
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>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<title> Counter Example </title>
<body>
<div align= "Center" > You are <font color= "#FF0000" ><%=application ("Counter")%></font> VIP!
</div>
</body>