Guest User

Popunder script that also works in FF4 and Chrome

a guest
Jun 2nd, 2011
1,192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var pu_url = "http://www.google.com";
  2. var pu_reruntime = 24; //hours
  3. var pu_width = 800;
  4. var pu_height = 1100;
  5.  
  6. function createCookie(b, e, f) {
  7.     var d = 60 * 60 * 1000 * f;
  8.     var a = new Date();
  9.     a.setTime(a.getTime() + (d));
  10.     var c = "; expires=" + a.toGMTString();
  11.     document.cookie = b + "=" + e + c + "; path=/";
  12. }
  13.  
  14. function getCookie(a) {
  15.     var b = document.cookie.match("(^|;) ?" + a + "=([^;]*)(;|$)");
  16.     if (b) {
  17.         return (unescape(b[2]));
  18.     }
  19.     else {
  20.         return null;
  21.     }
  22. }
  23.  
  24. function pu() {
  25.     if (getCookie("pu_timeout") == 1) {
  26.         return true;
  27.     }
  28.  
  29.     createCookie("pu_timeout", 1, pu_reruntime);
  30.     var b = "toolbar=0,statusbar=1,resizable=1,scrollbars=0,menubar=0,location=1,directories=0";
  31.  
  32.     if (navigator.userAgent.indexOf("Chrome") != -1) {
  33.         b = "scrollbar=yes";
  34.     }
  35.  
  36.     var a = window.open("about:blank", "", b + ",height=" + pu_width + ",width=" + pu_height);
  37.  
  38.     if (navigator.userAgent.indexOf("rv:2.") != -1) {
  39.         a.puPop = function (c) {
  40.             if (navigator.userAgent.indexOf("rv:2.") != -1) {
  41.                 this.window.open("about:blank").close();
  42.             }
  43.             this.document.location.href = c;
  44.         };
  45.         a.puPop(pu_url)
  46.     }
  47.     else {
  48.         a.document.location.href = pu_url;
  49.     }
  50.  
  51.     setTimeout(window.focus);
  52.     window.focus();
  53.  
  54.     if (a) {
  55.         a.blur();
  56.     }
  57.     else {
  58.         done_pu = null; ifSP2 = false;
  59.         if (typeof (pu_window) == "undefined") {
  60.             pu_window = false;
  61.         }
  62.         if (window.SymRealWinOpen) {
  63.             open = SymRealWinOpen;
  64.         }
  65.         if (window.NS_ActualOpen) {
  66.             open = NS_ActualOpen;
  67.         }
  68.  
  69.         ifSP2 = (navigator.userAgent.indexOf("SV1") != -1);
  70.  
  71.         if (!ifSP2) {
  72.             doPu();
  73.         }
  74.         else {
  75.             if (window.Event) {
  76.                 document.captureEvents(Event.CLICK);
  77.             }
  78.             document.onclick = doClickedPu;
  79.         }
  80.  
  81.         self.focus();
  82.         doClickedPu();
  83.     }
  84. }
  85.  
  86. function doPu() {
  87.     if (!pu_window) {
  88.         done_pu = open(pu_url, "", "toolbar=1,location=1,directories=0,status=1,menubar=1,scrollbars=1,resizable=1");
  89.  
  90.         if (done_pu) {
  91.             pu_window = true;
  92.             self.focus()
  93.         }
  94.     }
  95. }
  96.  
  97. function doClickedPu() {
  98.     if (!pu_window) {
  99.         if (!ifSP2) {
  100.             done_pu = open(pu_url, "", "toolbar=1,location=1,directories=0,status=1,menubar=1,scrollbars=1,resizable=1");
  101.             self.focus();
  102.  
  103.             if (done_pu) {
  104.                 pu_window = true;
  105.             }
  106.         }
  107.     }
  108.  
  109.     if (!pu_window) {
  110.         if (window.Event) {
  111.             document.captureEvents(Event.CLICK);
  112.         }
  113.  
  114.         document.onclick = doPu;
  115.         self.focus();
  116.     }
  117. }
  118.  
  119. function initPu() {
  120.     if (document.attachEvent) {
  121.         document.attachEvent("onclick", pu);
  122.     }
  123.     else if (document.addEventListener) {
  124.         document.addEventListener("click", pu, false);
  125.     }
  126.  
  127.     return true;
  128. }
  129.  
  130. initPu();
Advertisement
Add Comment
Please, Sign In to add comment