Recommended: Recommended: Summary of commonly used source code for beginners of ASP 1. Obtain system time: <%=now()%> 2. Obtain the IP used for visiting: <%=request.serverVariables(remote_host)%> 3. Obtain system, browser version: <script>
As an indispensable part of the website, the visitor counter can not only record the number of times the website is visited, but also enhance the fun and viewability of the web page through vivid and interesting design, making the visitor counter on the web page.
a landscape. The following are two ways to easily design interesting visitor counters, hoping that they will be helpful to everyone.
1. Material preparation
Fun visitor counter combines the design of the counter with interesting display effects. Ten counters of different styles appear randomly on the web page, adding some dynamic effects and fun to relatively static and serious web pages.
taste. During the first visit, the counter may display a static red number. During the second visit, the counter may become an animation that is constantly flipped. During the third visit, the counter may become from virtual to real again.
illusory variations. To achieve this effect, you first need to prepare some basic materials, namely, digital image files of ten display types. You can use graphic editing tools (such as Photoshop, Animator, etc.) to base yourself on your own
Imagination production can also be downloaded directly from the online image library, and then stored these digital images in the form of 00.gif...09.gif...90.gif...99.gif in a readable directory In the following example, this
These image files are stored in http://localhost/images. The principle of naming gif file here is: the first digit represents the display type, and the second digit represents the numeric value, such as 00.gif represents the gif text of 0 type 0 number 0
, 09.gif represents the gif file of type 0 number 9.
2. One of the design methods: use JavaScript to create interesting counters
1. Design idea:
The key to this method is the comprehensive application of cookie technology and dynamic image characteristics. Use cookies to record user data on the user's hard disk. The next time you visit this site, you can read the user's hard disk
Cookies, directly know the identity of the visitor and the number of visits and other related information. In JavaScript, access cookies through the document.cookie attribute, which includes name, expiration date, valid domain name, and valid
URL path, etc. The name separated by the equal sign and its value are the actual data of the cookie, which is used in this example to store the number of times the visitor visits the page. By mapping images in web pages to an image array, certain conditions
Modify the characteristics of this array item to realize dynamic image display. In this example, a set of images is first preloaded. Each time the web page is called, a new set of images is randomly generated, and a dynamic and interesting effect is achieved by overwriting the original image.
2. Source program count.html:
The following is the quoted content: <html > < head > < meta http-equiv=Content-Type content=text/html; charset=gb2312 > < title >Fun counter< /title > < /head > <body > < p < script language=JavaScript > var expdays=60; var exp=new Date(); exp.setTime(exp.getTime() (expdays*24*60*60*1000)); function count(info){ //If it is the first visit of the visitor, Assign the counter value by 1, otherwise add 1 to accumulate var wwwhcount=getcookie('wwhcount'); if (wwhcount==null){ wwhcount=1; } else{wwhcount ;} setcookie('wwhcount',wwhcount,exp); return countdisp(wwhcount) } function countdisp(countvar){ //Implement random display, less than 6 digits complete with 0, You can adjust the number of displayed digits yourself var countvar1=00000 countvar; var howFar1=countvar1.length; countvar1=countvar1.substring(howFar1, howFar1-1) var index= Math.floor(Math.random()*10); if (index==10){ index=0}; for (var icon=0;icount< 6;icount ){ var g=countvar1.substring(icount,icount 1); document.images[icount].src=http://www.yule21.com/info/http: //localhost/images/ index g .gif; } } function getCookieVal(offset){ //Get the number of visits that visitor var endstr=document.cookie.indexOf(;,offset); if (endstr==-1) endstr=document.cookie.length; return unescape(document.cookie.substring(offset,endstr)); } function getcookie(name){ //Intercept the name information segment in the cookie var arg=name =; var alen=arg.length; var clen=document.cookie.length; var i=0; while (i< clen){ var j=i alen; if (document.cookie.substring(i,j)==arg) return getCookieVal(j); i=document.cookie.indexOf( ,i) 1; if (i==0) break;} return null; } function setcookie(name,value){ //Storing the value of the guest counter var argv=setcookie.arguments; var argc=setcookie.arguments.length; var expires=(argc >2)?argv[2]:null; var path=(argc >3)?argv[3]:null; var domain=(argc >4)?argv[4]:null; var secure=(argc>5)?argv[5]:false; document.cookie=name = escape(value) ((expires==null)?:(;expires= expires.toGMTString())) ((path==null)?:(;path= path)) ((domain==null)? :(;domain= domain)) ((secure==true)?;secure:); } function deletecookie(name){ //Implement this information line to invalidate, Delete the user's information about the number of visits var exp=new Date(); exp.setTime(exp.getTime()-1); var cval=getcookie(name); document.cookie=name=cval ;expires= exp.toGMTString(); } < /script < /p > < ! --Preload the image array-- > You are the first to be < img src=/uploads/allimg/080822/0957231.gif height=20 width=20 > < img src=/uploads/allimg/080822/0957231.gif height=20 width=20 > < img src=/uploads/allimg/080822/0957231.gif height=20 width=20 > < img src=/uploads/allimg/080822/0957231.gif height=20 width=20 > < I mg src=/uploads/allimg/080822/0957231.gif height=20 width=20 > < img src=/uploads/allimg/080822/0957231.gif height=20 width=20 >Time visit! < script language=JavaScript > //Calling the count() function, Implement dynamic image display of counter count(); < /script > < /body > < /html > |
Share: 15 very useful examples in ASP programming 1. How to use Asp to determine the virtual physical path of your website Answer: Use the Mappath method as follows: <p align=center><font size=4
2 pages in total Previous page 12 Next page