网络实验室

 找回密码
 注册账户
查看: 1777|回复: 0

24小时弹一次 弹窗代码

[复制链接]
无心的棋子 发表于 2008-6-14 15:22:36 | 显示全部楼层 |阅读模式
  1. <script type="text/javascript">

  2. //1) specify URLs to randomly select from and pop-under:
  3. //To display a single URL, just remove all but the first entry below:
  4. var popunder=new Array()
  5. popunder[0]="http://www.cnlabs.net"


  6. //2) specify popunder window features
  7. //set 1 to enable a particular feature, 0 to disable
  8. var winfeatures="width=800,height=510,scrollbars=1,resizable=1,toolbar=1,location=1,menubar=1,status=1,directories=0"

  9. //3) Control frequency of the pop up:
  10. //"always", for every time page loads OR
  11. //"x hours" for once per x hours, where x is an integer (ie: 12 hours)

  12. var popfrequency="24 hours"

  13. ///No editing beyond here required/////

  14. function get_cookie(Name) {
  15.   var search = Name + "="
  16.   var returnvalue = "";
  17.   if (document.cookie.length > 0) {
  18.     offset = document.cookie.indexOf(search)
  19.     if (offset != -1) { // if cookie exists
  20.       offset += search.length
  21.       // set index of beginning of value
  22.       end = document.cookie.indexOf(";", offset);
  23.       // set index of end of cookie value
  24.       if (end == -1)
  25.          end = document.cookie.length;
  26.       returnvalue=unescape(document.cookie.substring(offset, end))
  27.       }
  28.    }
  29.   return returnvalue;
  30. }

  31. function resetcookie(){
  32. var expireDate = new Date()
  33. expireDate.setHours(expireDate.getHours()-10)
  34. document.cookie = "tcpopunder=;path=/;expires=" + expireDate.toGMTString()
  35. }

  36. function loadornot(){
  37. if (get_cookie('tcpopunder')==''){
  38. loadpopunder()
  39. var expireDate = new Date()
  40. expireDate.setHours(expireDate.getHours()+parseInt(popfrequency))
  41. document.cookie = "tcpopunder="+parseInt(popfrequency)+";path=/;expires=" + expireDate.toGMTString()
  42. }
  43. }

  44. function loadpopunder(){
  45. win2=window.open(popunder[Math.floor(Math.random()*(popunder.length))],"",winfeatures)
  46. win2.blur()
  47. window.focus()
  48. }

  49. if (popfrequency=="always"){
  50. resetcookie()
  51. loadpopunder()
  52. }
  53. else{
  54. if (get_cookie('tcpopunder')!=parseInt(popfrequency))
  55. resetcookie()
  56. loadornot()
  57. }
  58. </script>
复制代码
您需要登录后才可以回帖 登录 | 注册账户

本版积分规则

黑屋|存档|手机|网络实验室 本站服务器由美国合租以及IDCLayer国际数据提供!!!

GMT+8, 2024-4-28 22:39 , Processed in 0.085266 second(s), 11 queries , Gzip On, Redis On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表