通过cookie记录客户最近浏览页面,然后在当前页面动态显示出来,网址导航网站常用的一种网页特效,结合自己需求来修改。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta name="keywords" content="武鸣人网站,武鸣信息网,武鸣本地网,武鸣信息资源平台,减肥,健身,励志,励志语录,js特效,网页特效,www.wuming.ren"> <meta name="description" content="欢迎来到武鸣人信息资源平台,各种信息免费发布,资源共享合作共赢,分享互联网流行的励志语录经典短句,减肥健身健康小常识及打卡记录,收集各种js特效代码。"> <title>js实现记录最近浏览功能特效_武鸣人</title> <meta http-equiv="content-type" content="text/html;charset=gb2312"> <script language="javascript"> //cookie相关函数 function getCookieVal(offset){ var endstr = document.cookie.indexOf (";", offset); if (endstr == -1) endstr = document.cookie.length; return unescape(document.cookie.substring(offset, endstr)); }//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀) 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 exp = new Date(); exp.setTime (exp.getTime()+3600000000); document.cookie = name + "=" + value + "; expires=" + exp.toGMTString(); } function glog(evt){ evt=evt?evt:window.event; var srcElem=(evt.target)?evt.target:evt.srcElement; try{ while(srcElem.parentNode&&srcElem!=srcElem.parentNode){ if(srcElem.tagName&&srcElem.tagName.toUpperCase()=="A"){ linkname=srcElem.innerHTML; address=srcElem.href+"|"; wlink=linkname+"+"+address; old_info=getCookie("history_info"); var insert=true; if(old_info==null){//判断cookie是否为空 insert=true; }//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀) else{ var old_link=old_info.split("|"); for(var j=0;j<=5;j++){ if(old_link[j].indexOf(linkname)!=-1) insert=false; if(old_link[j]=="null") break; } } if(insert){ wlink+=getCookie("history_info"); setCookie("history_info",wlink); history_show().reload(); break; } else { var old_link1=old_info.split("|"); var length=old_link1.length var newcookie='' for(var j=0;length<=6?j<=length-1:j<=5;j++){ if(old_link1[j].indexOf(linkname)==-1) { if(j==length-1||j==5) { newcookie=newcookie+old_link1[j] } else { newcookie=newcookie+old_link1[j]+'|' } } }//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀) newcookie=wlink+newcookie setCookie("history_info",newcookie); history_show().reload(); break; } } srcElem = srcElem.parentNode; } } catch(e){} return true; } //document.onclick=glog; function history_show(){ var history_info=getCookie("history_info"); var content=""; if(history_info!=null){ history_arg=history_info.split("|"); var i; for(i=0;i<=5;i++){ if(history_arg[i]!="null"){ var wlink=history_arg[i].split("+"); content+=("<font color='#ff000'>↑</font>"+"<a href='"+wlink[1]+"' target='_blank'>"+wlink[0]+"</a><br>"); }//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀) document.getElementById("www_wuming_ren").innerHTML=content; } } else{ document.getElementById("www_wuming_ren").innerHTML="对不起,您没有任何浏览记录!请点击下面链接看效果"; } }//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀) </script> </head> <body> <a href="https://www.wuming.ren">武鸣人</a>,各种信息资源免费发布,分享励志语录经典短句,减肥健身常识,各种js特效代码。网站很好记住,wuming.ren(武鸣拼音.ren域名后缀)<hr> <!--欢迎来到武鸣人信息资源平台,各种信息免费发布,资源共享合作共赢,分享互联网流行的励志语录经典短句,减肥健身健康小常识及打卡记录,收集各种js特效代码。--> <script type="text/javascript" src="https://www.wuming.ren/ad/tc.js"></script> <script type="text/javascript" src="https://www.wuming.ren/ad/a.js"></script> <div>您最近关注的内容(只显示6个最近关注的内容并且不会重复出现):</div> <div id="www_wuming_ren"> <script language="javascript">history_show();</script> </div> <div> <br><br>请选择:<br> <a href="#" onclick="glog()">武鸣人一号</a> <a href="#" onclick="glog()">武鸣人二号</a> <a href="#" onclick="glog()">武鸣人三号</a> <a href="#" onclick="glog()">武鸣人四号</a> <a href="#" onclick="glog()">武鸣人五号</a> <a href="#" onclick="glog()">武鸣人六号</a> <a href="#" onclick="glog()">武鸣人七号</a> <a href="#" onclick="glog()">武鸣人八号</a> </div> </body> </html>
本文来自武鸣人网站,转载请注明出处