带有防刷新的记忆当前位置菜单
2011-01-24 12:04
344 查看
<!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> <title>带有防刷新的记忆当前位置菜单_网页代码站(www.webdm.cn)</title> <style> a{color:#5A73F3;text-decoration:none} body{background:#333;margin:30px;font-size:14px;} #menu li{float:left;height:25px;line-height:25px;list-style:none} #menu li a{padding:10px;} a:hover{background:#ccc;color:##3399FF} a.hover{height:25px;line-height:25px;background:red;color:#ffffff} a,area{blr:e-xpression(this.onFocus=this.blur())} :focus{-moz-outline-style:none;} </style> </head> <body> <div id="menu"> <ul> <li><a href="javascript:void(0)" class="hover" onclick="changename(0)" hidefocus="true">我的菜单</a></li> <li><a href="javascript:void(0)" onclick="changename(1)" hidefocus="true">网页模板</a></li> <li><a href="javascript:void(0)" onclick="changename(2)" hidefocus="true">精品代码</a></li> <li><a href="javascript:void(0)" onclick="changename(3)" hidefocus="true">设计素材</a></li> <li><a href="javascript:clear();" hidefocus="true">恢复初始</a></li> </ul> </div> <script language="javascript"> function changename(c,cl) { var d=document.getElementById("menu").getElementsByTagName("a"); if(!cl) { writeCookie("hovers",c,222); } c=readCookie("hovers")?readCookie("hovers"):c; for(i=0;i<d.length;i++) { d[i].className=i==c?"hover":""; } } function writeCookie(name, value, hours) { var expire = ""; if(hours != null) { expire = new Date((new Date()).getTime() + hours * 3600000); expire = "; expires=" + expire.toGMTString(); } document.cookie = name + "=" + escape(value) + expire; } // Example: // alert( readCookie("myCookie") ); function readCookie(name) { var cookieValue = ""; var search = name + "="; if(document.cookie.length > 0) { offset = document.cookie.indexOf(search); if (offset != -1) { offset += search.length; end = document.cookie.indexOf(";", offset); if (end == -1) end = document.cookie.length; cookieValue = unescape(document.cookie.substring(offset, end)) } } return cookieValue; } function clear() { writeCookie("hovers","",222); document.location=document.location.href; } changename(0,1) </script> </body> </html> <br> <p><a href="http://www.webdm.cn">网页代码站</a> - 最专业的代码下载网站 - 致力为中国站长提供有质量的代码!</p>
代码来自:http://www.webdm.cn/webcode/7460d56d-2c83-440e-999b-32012559b395.html
相关文章推荐
- 后台系统无刷新页面记录当前操作位置方法
- android中长按listview弹出菜单后如何在菜单选择方法中获取当前listview的位置
- 点滴积累【C#】---当前菜单所在位置(导航栏)
- 刷新dbgrid 而不失去当前行位置
- jQuery实现点击后标记当前菜单位置(背景高亮菜单)效果
- asp.net页面刷新保存当前位置
- 用TreeView控件在无限极节点上用Menu控件做导航菜单显示用户当前所在的页面的位置
- JS利用cookie记忆当前位置的防刷新导航效果
- 带有定位当前位置的百度地图web api 前端代码
- 一个帮助记忆对话框当前位置的C++类
- ASP.Net页面刷新保存当前位置
- 用Cookie来保存菜单当前位置代码
- JS利用cookie记忆当前位置的防刷新导航效果
- 在skyline中获取当前鼠标的位置坐标,屏蔽右键菜单
- 刷新时滚动条任然停留在当前位置
- css3--[转载][菜单导航] 带有记忆功能的多页面跳转导航菜单
- jQuery实现点击后标记当前菜单位置(背景高亮菜单)效果
- ASP.Net页面刷新保存当前位置
- 带有定位当前位置的百度地图前端web api实例代码
- ASP.Net页面刷新保存当前位置