网站首页 >> 用按钮查看访问者访问页面的次数,而且可以重新开始计数
发布于:2008-10-28 已被阅读: 次 来源:上海青浦网站建设
<HTML><HEAD><META http-equiv='Content-Type' content='text/html; charset=gb2312'><TITLE>用按钮查看访问者访问页面的次数,而且可以重新开始计数</TITLE></HEAD><BODY bgcolor="#fef4d9" onload="DisplayInfo()"><SCRIPT LANGUAGE="JavaScript"><!-- Begin function getCookieVal (offset) {var endstr = document.cookie.indexOf (";", offset);if (endstr == -1)endstr = document.cookie.length;return unescape(document.cookie.substring(offset, endstr));}function GetCookie (name) {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) {var argv = SetCookie.arguments;var argc = SetCookie.arguments.length;var expires = (2 < argc) ? argv[2] : null;var path = (3 < argc) ? argv[3] : null;var domain = (4 < argc) ? argv[4] : null;var secure = (5 < argc) ? 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 DisplayInfo() {var expdate = new Date();var visit;expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000 * 365)); if(!(visit = GetCookie("visit"))) visit = 0;visit++;SetCookie("visit", visit, expdate, "/", null, false);var message;if(visit == 1) message=" Welcome to my page!";if(visit== 2) message=" I see you came back !";if(visit == 3) message=" Oh, it's you again!";if(visit == 4)message=" You must be curious!"; if(visit == 5) message=" You're practically a regular!";if(visit == 6) message=" You need a hobby!";if(visit == 7)message=" Nothing better to do?"; if(visit == 8) message=" Don't you ever sleep?";if(visit == 9)message=" Get a life!!!"; if(visit >= 10) message=" Rent is due on the 1st of the month!"; alert("\n"+"你的浏览器已经访问过本页" + visit +"次了"+"\n"+"\n"+message);}function ResetCounts() {var expdate = new Date();expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000 * 365)); visit = 0;SetCookie("visit", visit, expdate , "/", null, false);history.go(0);}// End --></Script><FORM><CENTER><INPUT NAME="update" TYPE="BUTTON" VALUE="查看次数" OnClick="history.go(0)"><INPUT NAME="reset" TYPE="BUTTON" VALUE="重新计数" OnClick="ResetCounts()"></CENTER></FORM></BODY></HTML> <!-- 要实现此效果需要 2 个步骤: --><!-- 第 1 步: --><!-- 把<BODY>中的属性代码改为: --><BODY bgcolor="#fef4d9" onload="DisplayInfo()"><!-- 第 2 步: --><!-- 把下面的代码加到<BODY></BODY>区域中: --><SCRIPT LANGUAGE="JavaScript"><!-- Begin function getCookieVal (offset) {var endstr = document.cookie.indexOf (";", offset);if (endstr == -1)endstr = document.cookie.length;return unescape(document.cookie.substring(offset, endstr));}function GetCookie (name) {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) {var argv = SetCookie.arguments;var argc = SetCookie.arguments.length;var expires = (2 < argc) ? argv[2] : null;var path = (3 < argc) ? argv[3] : null;var domain = (4 < argc) ? argv[4] : null;var secure = (5 < argc) ? 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 DisplayInfo() {var expdate = new Date();var visit;expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000 * 365)); if(!(visit = GetCookie("visit"))) visit = 0;visit++;SetCookie("visit", visit, expdate, "/", null, false);var message;if(visit == 1) message=" Welcome to my page!";if(visit== 2) message=" I see you came back !";if(visit == 3) message=" Oh, it's you again!";if(visit == 4)message=" You must be curious!"; if(visit == 5) message=" You're practically a regular!";if(visit == 6) message=" You need a hobby!";if(visit == 7)message=" Nothing better to do?"; if(visit == 8) message=" Don't you ever sleep?";if(visit == 9)message=" Get a life!!!"; if(visit >= 10) message=" Rent is due on the 1st of the month!"; alert("\n"+"你的浏览器已经访问过本页" + visit +"次了"+"\n"+"\n"+message);}function ResetCounts() {var expdate = new Date();expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000 * 365)); visit = 0;SetCookie("visit", visit, expdate , "/", null, false);history.go(0);}// End --></Script><FORM><CENTER><INPUT NAME="update" TYPE="BUTTON" VALUE="查看次数" OnClick="history.go(0)"><INPUT NAME="reset" TYPE="BUTTON" VALUE="重新计数" OnClick="ResetCounts()"></CENTER></FORM>
手机:13482597886
Q Q:41218056
qq41218056@hotmail.com
英文网站建设与中文网站
日文网站建设-日文网站设计
走好电子商务网站的建设
八大要领 做网站就这么简单
电子商务十忌与建设网站
优秀网站制作的五大要素
网站功能设计的适用性评价
高级技巧:个性化网站设计
行业网站的设计心得
从网页到网络平台 网站开
网站文化与网页设计
一个成功的网站设计
网站建设项目合同撰写注意
企业如何准备网站建设资料
网站建设需要策划吗?
网络营销市场回顾与展望
企业网站建设有哪些不足
网站推广时几点禁忌 上海
网站设计应注意的25条
网站策划方案写作、演示
网站推广技巧--实战中文
网站开发策划所需要的文档
企业网站推广效果分析
如何做好网站开发项目的
企业网站的推广漫谈 上海
最佳适合于网站海外推广
网站策划,需要什么的人才
网站策划与建设阶段网站推
网络营销中网站个性化设计