Four steps to complete ASP Web Design flow Statistics _ Application Skills

Source: Internet
Author: User

Follow these steps, step by step, and you'll soon have exquisite graphical counters.  
Step 1: Create a text file, such as counter.dat   , to store the amount of traffic under a directory in a Web site, such as count. The contents of the file have only one row of numbers, which indicates the initial visit of the site, typically 0.
Step 2: Create a counter in the same directory ASP program, can be named Mycount.asp, the contents are as follows:     

 <% ' self-compiling ASP graphical counter V1.1 ' for web browsing statistics, free use, free copy! Dim vistors ' Get Count file Counter.dat address Countfile=server.mappath ("Counter.dat") ' Create FileSystemObject object instance FS set Fs=s Erver.createobject ("Scripting.FileSystemObject") ' opens the file as read, where 1 is read as set Thisfile=fs.opentextfile (Countfile,1,false , FALSE) ' reads the contents of the Count file Visitors=thisfile.readline ' closes the file thisfile.close set Fs=server.createobject ("Scriptin G.filesystemobject ")" to Overwrite (TRUE), create file Set Thisfile=fs.createtextfile (countfile,true,false) in ASCII format (FALSE) Key to the number: ' Add a variable connected to determine if the visitor is a new connector ' This prevents the same user from browsing in the same browser because the "Refresh" button is clicked repeatedly, causing the value of the counter to rise continuously if isempty (SE Ssion ("Connected")) then Application.Lock ' prevent other users from changing the value of the Counter visitors=visitors+1 ' counter value plus 1 THISFI 
     Le.writeline (visitors) ' Write results to file Application.UnLock ' unlock, allowing the user to change the value of the counter else Application.Lock Visitors=visitors Thisfile.writeline (visitors) Application.UnLock end If session ("Connected") =true ' Set caller as connected (TRUE), press the ' Refresh ' button counter value will not change. Countlen=len (visitors) ' Gets the length of the counter value (that is, the number of digits) ' If you do not want to use graphics, you can replace the For/next loop ' text counter with the following: Response.Write ' Document.wri Te ("&visitors&"); "'  Bitwise display of graphical numbers for I=1 to Countlen Response.Write "document.write (' </img> ');" Next ' closes the file thisfile.close set fs=nothing%>

Step 3: put the Counter.dat, mycount.asp files in the same directory (also can be stored separately, but you need to specify the file path), and in this directory to create a images directory, stored in a graphical digital file, The number 0 corresponds to the 0.gif, the number 1 corresponds to 1.gif, and so on (the opportunity to show your personality comes, you can do it very cool).
Step 4: at this point, the success will be success. You only need to use the following format in the Web page to invoke the counter:

 <script  language= "javascript"  src= "count/mycount.asp" >  
</script>

Note: (1) If you use a different directory name, file name, please make corresponding changes;
(2) The Counter program using ASP programming, please test on the website or in the personal server PWS debugging;

As long as the above four steps we carefully study, I believe you will be able to produce a feature of their own style of ASP Web page design flow statistics.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.