oohnajra

Popunder script that also works in FF5 and Chrome

Jun 2nd, 2011
476
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 = 1100;
  4. var pu_height = 800;
  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 + ",width=" + pu_width + ",height=" + pu_height);
  37.  
  38.     if (navigator.userAgent.indexOf("rv:2.") != -1 || navigator.userAgent.indexOf("rv:5.") != -1) {
  39.         a.puPop = function (c) {
  40.             if (navigator.userAgent.indexOf("rv:2.") != -1 || navigator.userAgent.indexOf("rv:5.") != -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;
  59.         ifSP2 = false;
  60.  
  61.         if (typeof (pu_window) == "undefined") {
  62.             pu_window = false;
  63.         }
  64.         if (window.SymRealWinOpen) {
  65.             open = SymRealWinOpen;
  66.         }
  67.         if (window.NS_ActualOpen) {
  68.             open = NS_ActualOpen;
  69.         }
  70.  
  71.         ifSP2 = (navigator.userAgent.indexOf("SV1") != -1);
  72.  
  73.         if (!ifSP2) {
  74.             doPu();
  75.         }
  76.         else {
  77.             if (window.Event) {
  78.                 document.captureEvents(Event.CLICK);
  79.             }
  80.             document.onclick = doClickedPu;
  81.         }
  82.  
  83.         self.focus();
  84.         doClickedPu();
  85.     }
  86. }
  87.  
  88. function doPu() {
  89.     if (!pu_window) {
  90.         done_pu = open(pu_url, "", "toolbar=1,location=1,directories=0,status=1,menubar=1,scrollbars=1,resizable=1");
  91.  
  92.         if (done_pu) {
  93.             pu_window = true;
  94.             self.focus();
  95.         }
  96.     }
  97. }
  98.  
  99. function doClickedPu() {
  100.     if (!pu_window) {
  101.         if (!ifSP2) {
  102.             done_pu = open(pu_url, "", "toolbar=1,location=1,directories=0,status=1,menubar=1,scrollbars=1,resizable=1");
  103.             self.focus();
  104.  
  105.             if (done_pu) {
  106.                 pu_window = true;
  107.             }
  108.         }
  109.     }
  110.  
  111.     if (!pu_window) {
  112.         if (window.Event) {
  113.             document.captureEvents(Event.CLICK);
  114.         }
  115.  
  116.         document.onclick = doPu;
  117.         self.focus();
  118.     }
  119. }
  120.  
  121. function initPu() {
  122.     if (document.attachEvent) {
  123.         document.attachEvent("onclick", pu);
  124.     }
  125.     else if (document.addEventListener) {
  126.         document.addEventListener("click", pu, false);
  127.     }
  128.  
  129.     return true;
  130. }
  131.  
  132. initPu();
Advertisement
Add Comment
Please, Sign In to add comment