Advertisement
silasvasconcelos

Open window in x secounds

Dec 25th, 2015
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 4.54 KB | None | 0 0
  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4.     function makePopunder(pUrl) {
  5.     var _parent = (top != self && typeof (top["document"]["location"].toString()) === "string") ? top : self;
  6.     var mypopunder = null;
  7.     var pName = (Math["floor"]((Math["random"]() * 1000) + 1));
  8.     var pWidth = window["innerWidth"];
  9.     var pHeight = window["innerHeight"];
  10.     var pPosX = window["screenX"];
  11.     var pPosY = window["screenY"];
  12.     var pWait = 3600;
  13.     pWait = (pWait * 1000);
  14.     var pCap = 50000;
  15.     var todayPops = 0;
  16.     var cookie = "_.mypopunder";
  17.     var browser = function () {
  18.         var n = navigator["userAgent"]["toLowerCase"]();
  19.         var b = {
  20.             webkit: /webkit/ ["test"](n),
  21.             mozilla: (/mozilla/ ["test"](n)) && (!/(compatible|webkit)/ ["test"](n)),
  22.            chrome: /chrome/ ["test"](n),
  23.            msie: (/msie/ ["test"](n)) && (!/opera/ ["test"](n)),
  24.            firefox: /firefox/ ["test"](n),
  25.            safari: (/safari/ ["test"](n) && !(/chrome/ ["test"](n))),
  26.            opera: /opera/ ["test"](n)
  27.        };
  28.         b["version"] = (b["safari"]) ? (n["match"](/.+(?:ri)[\/: ]([\d.]+)/) || [])[1] : (n["match"](/.+(?:ox|me|ra|ie)[\/: ]([\d.]+)/) || [])[1];
  29.         return b;
  30.     }();
  31.  
  32.     function isCapped() {
  33.         try {
  34.             todayPops = Math["floor"](document["cookie"]["split"](cookie + "Cap=")[1]["split"](";")[0]);
  35.         } catch (err) {};
  36.         return (pCap <= todayPops || document["cookie"]["indexOf"](cookie + "=") !== -1);
  37.    };
  38.  
  39.    function doPopunder(pUrl, pName, pWidth, pHeight, pPosX, pPosY) {
  40.        if (isCapped()) {
  41.            return;
  42.        };
  43.        var sOptions = "toolbar=no,scrollbars=yes,location=yes,statusbar=yes,menubar=no,resizable=1,width=" + pWidth.toString() + ",height=" + pHeight.toString() + ",screenX=" + pPosX + ",screenY=" + pPosY;
  44.  
  45.            window["pop_clicked"] = 1;
  46.            mypopunder = _parent["window"]["open"](pUrl, pName, sOptions);
  47.            if (mypopunder) {
  48.                var now = new Date();
  49.                document["cookie"] = cookie + "=1;expires=" + new Date(now["setTime"](now["getTime"]() + pWait))["toGMTString"]() + ";path=/";
  50.                now = new Date();
  51.                document["cookie"] = cookie + "Cap=" + (todayPops + 1) + ";expires=" + new Date(now["setTime"](now["getTime"]() + (84600 * 1000)))["toGMTString"]() + ";path=/";
  52.                pop2under();
  53.            };
  54.    };
  55.  
  56.    function pop2under() {
  57.        try {
  58.            mypopunder["blur"]();
  59.            mypopunder["opener"]["window"]["focus"]();
  60.            window["self"]["window"]["blur"]();
  61.            window["focus"]();
  62.            if (browser["firefox"]) {
  63.                openCloseWindow();
  64.            };
  65.            if (browser["webkit"]) {
  66.                openCloseTab();
  67.            };
  68.        } catch (e) {};
  69.    };
  70.  
  71.    function openCloseWindow() {
  72.        var ghost = window["open"]("about:blank");
  73.        ghost["focus"]();
  74.        ghost["close"]();
  75.    };
  76.  
  77.    function openCloseTab() {
  78.        var ghost = document["createElement"]("a");
  79.        ghost["href"] = "about:blank";
  80.        ghost["target"] = "PopHelper";
  81.        document["getElementsByTagName"]("body")[0]["appendChild"](ghost);
  82.        ghost["parentNode"]["removeChild"](ghost);
  83.        var clk = document["createEvent"]("MouseEvents");
  84.        clk["initMouseEvent"]("click", true, true, window, 0, 0, 0, 0, 0, true, false, false, true, 0, null);
  85.        ghost["dispatchEvent"](clk);
  86.        window["open"]("about:blank", "PopHelper")["close"]();
  87.    };
  88.  
  89.    function pop_isRightButtonClicked(e) {
  90.        var rightclick = false;
  91.        e = e || window["event"];
  92.        if (e["which"]) {
  93.            rightclick = (e["which"] == 3);
  94.        } else {
  95.            if (e["button"]) {
  96.                rightclick = (e["button"] == 2);
  97.            };
  98.        };
  99.        return rightclick;
  100.    };
  101.    if (isCapped()) {
  102.        return;
  103.    } else {
  104.        doPopunder(pUrl, pName, pWidth, pHeight, pPosX, pPosY);
  105.    };
  106. }
  107.  
  108. // Função para abrir popup em x segundos
  109. function loaded(){
  110.            // Tempo de espera, você pode adicionar 1000 para cada segundo
  111.            // 5000 = 5 segundos, 3000 = 3 segundos
  112.            var open_in = 3000;
  113.            // Função sera executa apos o tempo de esperar
  114.            setTimeout(function () {
  115.                makePopunder("http://www.google.com/");
  116.            }, open_in);
  117.        };
  118.  
  119. </script>
  120.  
  121. </head>
  122. <body onload="loaded();">
  123. <p>click anywhere in the page</p>
  124. </body>
  125. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement