流量变现70%分成 全国楼凤小姐姐 招商联系客服 招商联系客服 招商联系客服 招商联系客服

各种页面常用的弹窗代码大全-用Cookie实现仅弹出一次窗口

[复制链接]
查看165 | 回复0 | 2024-9-23 12:46:20 | 显示全部楼层 |阅读模式
用Cookie实现仅弹出一次窗口

脚本说明:
第一步:把如下代码加入<head>区域中 复制内容到剪贴板
代码:
  1. <SCRIPT language="javascript"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
  2. <!--<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
  3. function openpopup(){<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
  4. window.open("welcome.htm","","width=300,height=300")<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
  5. }<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
  6. function get_cookie(Name) {<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
  7. var search = Name + "="<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
  8. var returnvalue = "";<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
  9. if (documents.cookie.length > 0) {<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
  10. offset = documents.cookie.indexOf(search)<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
  11. if (offset != -1) { // if cookie exists<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
  12. offset += search.length<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
  13. // set index of beginning of value<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
  14. end = documents.cookie.indexOf(";", offset);<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
  15. // set index of end of cookie value<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
  16. if (end == -1)<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
  17. end = documents.cookie.length;<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
  18. returnvalue="/(documents.cookie.substring(offset," end))<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
  19. }<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
  20. }<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
  21. return returnvalue;<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
  22. }<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
  23. function loadpopup(){<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
  24. if (get_cookie('popped')=='){<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
  25. openpopup()<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
  26. documents.cookie="popped=yes"<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
  27. }<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
  28. }<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
  29. //--><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
  30. </SCRIPT>
复制代码

第二步:把<body>中内容改为:
复制内容到剪贴板
代码:
  1. <body bgcolor="#fef4d9" >
复制代码



回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则