Loading... ###运用cookie 使弹出层只显示一次 运用cookie的原理,一个页面只提示一次的DIV提示层。特别适合于页面的功能小提示等。可以做出类似QQ空间的功能提示。 ~~~ <!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 http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>怪兽怪秀-Guaishow.cn</title> <style> .note{height:100px;width:600px;) #FEFFCF 40px 0px no-repeat;border:#EDCE7B 1px solid;} .guanbi{float:right;font-size:12px;padding:6px;} </style> <script> function cookiesave(n, v, mins, dn, path) { if(n) { if(!mins) mins = 365 * 24 * 60; if(!path) path = "/"; var date = new Date(); date.setTime(date.getTime() + (mins * 60 * 1000)); var expires = "; expires=" + date.toGMTString(); if(dn) dn = "domain=" + dn + "; "; document.cookie = n + "=" + v + expires + "; " + dn + "path=" + path; } } function cookieget(n) { var name = n + "="; var ca = document.cookie.split(';'); for(var i=0;i<ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(name) == 0) return c.substring(name.length,c.length); } return ""; } function closeclick(){ document.getElementById('note').style.display='none'; cookiesave('closeclick','closeclick','','',''); } function clickclose(){ if(cookieget('closeclick')=='closeclick'){ document.getElementById('note').style.display='none'; }else{ document.getElementById('note').style.display='block'; } } window.onload=clickclose; </script> </head> <body> <div id="note" class="note" style="display:none;"> <be /> <p>这里是一个第一次进入页面的提示语!</p> <div><a href="#" onclick="closeclick()" class="guanbi">我知道了 X </a></div> </div> </body> </html> ~~~ --- ### 在文件夹底部添加说明: > 在 OneDrive 的文件夹中添加README.md文件,使用 Markdown 语法。 ### 在文件夹头部添加说明: > 在 OneDrive 的文件夹中添加HEAD.md 文件,使用 Markdown 语法。 ### 加密文件夹: > 在 OneDrive 的文件夹中添加.password文件,填入密码,密码不能为空。 ### 直接输出网页: > 在 OneDrive 的文件夹中添加index.html 文件,程序会直接输出网页而不列目录。 > 配合 文件展示设置-直接输出 效果更佳。 Last modification:May 23, 2021 © Allow specification reprint Support Appreciate the author WeChat Like 0 如果觉得我的文章对你有用,请帮忙点一下上面的广告