1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

[GET] Javascript POPUNDER script, Monetize your traffic through popups / popunder

Discussion in 'HTML & JavaScript' started by phpfail, Jun 16, 2012.

  1. phpfail

    phpfail Regular Member

    Joined:
    Aug 21, 2011
    Messages:
    237
    Likes Received:
    105
    Occupation:
    Webmaster / Internet Marketer
    ENJOY:) Leave some thanks!

    [

    Code:
    [var puShown = false;
    var PopWidth = 1370;
    var PopHeight = 800;
    var PopFocus = 0;
    var _Top = null;
    
    function GetWindowHeight() {
        var myHeight = 0;
        if (typeof (_Top.window.innerHeight) == 'number') {
            myHeight = _Top.window.innerHeight;
        } else if (_Top.document.documentElement && _Top.document.documentElement.clientHeight) {
            myHeight = _Top.document.documentElement.clientHeight;
        } else if (_Top.document.body && _Top.document.body.clientHeight) {
            myHeight = _Top.document.body.clientHeight;
        }
        return myHeight;
    }
    
    function GetWindowWidth() {
        var myWidth = 0;
        if (typeof (_Top.window.innerWidth) == 'number') {
            myWidth = _Top.window.innerWidth;
        } else if (_Top.document.documentElement && _Top.document.documentElement.clientWidth) {
            myWidth = _Top.document.documentElement.clientWidth;
        } else if (_Top.document.body && _Top.document.body.clientWidth) {
            myWidth = _Top.document.body.clientWidth;
        }
        return myWidth;
    }
    
    function GetWindowTop() {
        return (_Top.window.screenTop != undefined) ? _Top.window.screenTop : _Top.window.screenY;
    }
    
    function GetWindowLeft() {
        return (_Top.window.screenLeft != undefined) ? _Top.window.screenLeft : _Top.window.screenX;
    }
    
    function doOpen(url) {
        var popURL = "about:blank"
        var popID = "ad_" + Math.floor(89999999 * Math.random() + 10000000);
        var pxLeft = 0;
        var pxTop = 0;
        pxLeft = (GetWindowLeft() + (GetWindowWidth() / 2) - (PopWidth / 2));
        pxTop = (GetWindowTop() + (GetWindowHeight() / 2) - (PopHeight / 2));
    
        if (puShown == true) {
            return true;
        }
    
        var PopWin = _Top.window.open(popURL, popID, 'toolbar=0,scrollbars=1,location=1,statusbar=1,menubar=0,resizable=1,top=' + pxTop + ',left=' + pxLeft + ',width=' + PopWidth + ',height=' + PopHeight);
    
        if (PopWin) {
            puShown = true;
    
            if (PopFocus == 0) {
                PopWin.blur();
    
                if (navigator.userAgent.toLowerCase().indexOf("applewebkit") > -1) {
                    _Top.window.blur();
                    _Top.window.focus();
                }
            }
    
            PopWin.Init = function (e) {
    
                with(e) {
    
                    Params = e.Params;
                    Main = function () {
    
                        if (typeof window.mozPaintCount != "undefined") {
                            var x = window.open("about:blank");
                            x.close();
    
                        }
    
                        var popURL = Params.PopURL;
    
                        try {
                            opener.window.focus();
                        } catch (err) {}
    
                        window.location = popURL;
                    }
    
                    Main();
                }
            };
    
            PopWin.Params = {
                PopURL: url
            }
    
            PopWin.Init(PopWin);
        }
    
        return PopWin;
    }
    
    function setCookie(name, value, time) {
        var expires = new Date();
    
        expires.setTime(expires.getTime() + time);
    
        document.cookie = name + '=' + value + '; path=/;' + '; expires=' + expires.toGMTString();
    }
    
    function getCookie(name) {
        var cookies = document.cookie.toString().split('; ');
        var cookie, c_name, c_value;
    
        for (var n = 0; n < cookies.length; n++) {
            cookie = cookies[n].split('=');
            c_name = cookie[0];
            c_value = cookie[1];
    
            if (c_name == name) {
                return c_value;
            }
        }
    
        return null;
    }
    
    function initPu() {
    
        _Top = self;
    
        if (top != self) {
            try {
                if (top.document.location.toString()) _Top = top;
            } catch (err) {}
        }
    
        if (document.attachEvent) {
            document.attachEvent('onclick', checkTarget);
        } else if (document.addEventListener) {
            document.addEventListener('click', checkTarget, false);
        }
    }
    
    function checkTarget(e) {
        if (!getCookie('popundr')) {
            var e = e || window.event;
            var win = doOpen('YOUR URL HERE');
    
            setCookie('popundr', 1, 24 * 60 * 60 * 1000);
        }
    }
    
    initPu();
     
    • Thanks Thanks x 9
    Last edited: Jun 17, 2012
  2. Four Seasons

    Four Seasons Regular Member

    Joined:
    Aug 22, 2011
    Messages:
    411
    Likes Received:
    206
    Location:
    Cottonballs
    Does not work in my part. And how to set URL?
     
  3. WizGizmo

    WizGizmo Super Moderator Staff Member Moderator Jr. VIP Premium Member

    Joined:
    Mar 28, 2008
    Messages:
    4,182
    Likes Received:
    55,948
    NOTE: Since this is not actually a download, I have
    moved this thread to the HTML & Javascript section.

    "Wiz"
     
    • Thanks Thanks x 1
  4. sockpuppet

    sockpuppet Junior Member

    Joined:
    Nov 7, 2011
    Messages:
    155
    Likes Received:
    145
    Because the code has a lot of html entities in it, like & "

    cleaned code:
    Code:
    var puShown = false;
    var PopWidth = 1370;
    var PopHeight = 800;
    var PopFocus = 0;
    var _Top = null;
    
    function GetWindowHeight() {
        var myHeight = 0;
        if (typeof (_Top.window.innerHeight) == 'number') {
            myHeight = _Top.window.innerHeight;
        } else if (_Top.document.documentElement && _Top.document.documentElement.clientHeight) {
            myHeight = _Top.document.documentElement.clientHeight;
        } else if (_Top.document.body && _Top.document.body.clientHeight) {
            myHeight = _Top.document.body.clientHeight;
        }
        return myHeight;
    }
    
    function GetWindowWidth() {
        var myWidth = 0;
        if (typeof (_Top.window.innerWidth) == 'number') {
            myWidth = _Top.window.innerWidth;
        } else if (_Top.document.documentElement && _Top.document.documentElement.clientWidth) {
            myWidth = _Top.document.documentElement.clientWidth;
        } else if (_Top.document.body && _Top.document.body.clientWidth) {
            myWidth = _Top.document.body.clientWidth;
        }
        return myWidth;
    }
    
    function GetWindowTop() {
        return (_Top.window.screenTop != undefined) ? _Top.window.screenTop : _Top.window.screenY;
    }
    
    function GetWindowLeft() {
        return (_Top.window.screenLeft != undefined) ? _Top.window.screenLeft : _Top.window.screenX;
    }
    
    function doOpen(url) {
        var popURL = "about:blank"
        var popID = "ad_" + Math.floor(89999999 * Math.random() + 10000000);
        var pxLeft = 0;
        var pxTop = 0;
        pxLeft = (GetWindowLeft() + (GetWindowWidth() / 2) - (PopWidth / 2));
        pxTop = (GetWindowTop() + (GetWindowHeight() / 2) - (PopHeight / 2));
    
        if (puShown == true) {
            return true;
        }
    
        var PopWin = _Top.window.open(popURL, popID, 'toolbar=0,scrollbars=1,location=1,statusbar=1,menubar=0,resizable=1,top=' + pxTop + ',left=' + pxLeft + ',width=' + PopWidth + ',height=' + PopHeight);
    
        if (PopWin) {
            puShown = true;
    
            if (PopFocus == 0) {
                PopWin.blur();
    
                if (navigator.userAgent.toLowerCase().indexOf("applewebkit") > -1) {
                    _Top.window.blur();
                    _Top.window.focus();
                }
            }
    
            PopWin.Init = function (e) {
    
                with(e) {
    
                    Params = e.Params;
                    Main = function () {
    
                        if (typeof window.mozPaintCount != "undefined") {
                            var x = window.open("about:blank");
                            x.close();
    
                        }
    
                        var popURL = Params.PopURL;
    
                        try {
                            opener.window.focus();
                        } catch (err) {}
    
                        window.location = popURL;
                    }
    
                    Main();
                }
            };
    
            PopWin.Params = {
                PopURL: url
            }
    
            PopWin.Init(PopWin);
        }
    
        return PopWin;
    }
    
    function setCookie(name, value, time) {
        var expires = new Date();
    
        expires.setTime(expires.getTime() + time);
    
        document.cookie = name + '=' + value + '; path=/;' + '; expires=' + expires.toGMTString();
    }
    
    function getCookie(name) {
        var cookies = document.cookie.toString().split('; ');
        var cookie, c_name, c_value;
    
        for (var n = 0; n < cookies.length; n++) {
            cookie = cookies[n].split('=');
            c_name = cookie[0];
            c_value = cookie[1];
    
            if (c_name == name) {
                return c_value;
            }
        }
    
        return null;
    }
    
    function initPu() {
    
        _Top = self;
    
        if (top != self) {
            try {
                if (top.document.location.toString()) _Top = top;
            } catch (err) {}
        }
    
        if (document.attachEvent) {
            document.attachEvent('onclick', checkTarget);
        } else if (document.addEventListener) {
            document.addEventListener('click', checkTarget, false);
        }
    }
    
    function checkTarget(e) {
        if (!getCookie('popundr')) {
            var e = e || window.event;
            var win = doOpen('YOUR URL HERE');
    
            setCookie('popundr', 1, 24 * 60 * 60 * 1000);
        }
    }
    
    initPu();
    
     
    • Thanks Thanks x 8
  5. rakall

    rakall Registered Member

    Joined:
    Mar 10, 2012
    Messages:
    54
    Likes Received:
    23
    thank you , that code does work.
     
    • Thanks Thanks x 2
  6. acooper18

    acooper18 Newbie

    Joined:
    May 27, 2012
    Messages:
    19
    Likes Received:
    1
    How can we geotarget the pops?
     
  7. criticalmess

    criticalmess Regular Member

    Joined:
    Feb 7, 2009
    Messages:
    237
    Likes Received:
    210
    use openx to show diff popunder script per geo location.

    openx gives you 100 mil monthly impressions for free
     
  8. muchacho

    muchacho Supreme Member

    Joined:
    May 14, 2009
    Messages:
    1,293
    Likes Received:
    188
    Location:
    Lancashire, England.
    Silly question time, but where in this code is the URL that will be shown inside the popunder?
     
  9. skrode

    skrode Junior Member

    Joined:
    Nov 13, 2011
    Messages:
    103
    Likes Received:
    16
    search for: var win = doOpen('YOUR URL HERE');
     
    • Thanks Thanks x 2
  10. muchacho

    muchacho Supreme Member

    Joined:
    May 14, 2009
    Messages:
    1,293
    Likes Received:
    188
    Location:
    Lancashire, England.
    Cheers, and does this code go inside the functions.php of the theme?
     
  11. sirgold

    sirgold BANNED BANNED

    Joined:
    Jun 25, 2010
    Messages:
    1,260
    Likes Received:
    646
    On FF 14 it fires up a popup not a popunder for me, not a popunder. Works fine in Chrome and Opera.
     
  12. skrode

    skrode Junior Member

    Joined:
    Nov 13, 2011
    Messages:
    103
    Likes Received:
    16
    Add the code into header, just before </head> tag and wrap the code with <script type="text/javascript"></script> tags.
     
    • Thanks Thanks x 2
  13. muchacho

    muchacho Supreme Member

    Joined:
    May 14, 2009
    Messages:
    1,293
    Likes Received:
    188
    Location:
    Lancashire, England.
    On mine nothing happens on Firefox.

    On IE it does work as a popunder though.
     
  14. sirgold

    sirgold BANNED BANNED

    Joined:
    Jun 25, 2010
    Messages:
    1,260
    Likes Received:
    646
    For FF it works when you click "anywhere" on the page, here.. Also make sure to RESTART FF each time, since the script sets a cookie and the popunder won't be fired more than once per session ;)
     
  15. Jentage

    Jentage Registered Member

    Joined:
    Sep 21, 2011
    Messages:
    59
    Likes Received:
    16
    what URL are you supposed to put there exactly?
     
  16. intellex

    intellex Newbie

    Joined:
    Dec 29, 2009
    Messages:
    23
    Likes Received:
    0
    Doesn't seem to work in Chrome, works perfectly in IE9 and Firefox 15... but not Chrome.

    Does anybody have a fix for Chrome?
     
  17. khoosat

    khoosat Regular Member

    Joined:
    Dec 21, 2008
    Messages:
    201
    Likes Received:
    2
    how do I make this to pop up after every 1 minute instead of once every 24 hours?
    And any chance to rotate the pop up url :)?
     
  18. psicoz

    psicoz Newbie

    Joined:
    Oct 3, 2011
    Messages:
    27
    Likes Received:
    2
    Location:
    somewhere
    works like a charm... thank you !
     
  19. zullum

    zullum Registered Member

    Joined:
    Mar 8, 2011
    Messages:
    85
    Likes Received:
    9
    Is there any way to set this to work after the visitor clicks anywhere on the site?
     
  20. crazymonster

    crazymonster Junior Member

    Joined:
    Apr 8, 2011
    Messages:
    132
    Likes Received:
    20
    Home Page:
    Dont work i think ?