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

How to make a pop-under?

Discussion in 'Blogging' started by WhiteBoi360, May 10, 2013.

  1. WhiteBoi360

    WhiteBoi360 Regular Member

    Joined:
    Mar 14, 2012
    Messages:
    241
    Likes Received:
    43
    Location:
    Tennessee
    I've googled and tried a few codes/scripts but they don't seem to be working as they are supposed to... I want something like PirateBay's.(pop up blocker doesn't even block theirs) Where the page loads BEHIND the browser or minimized. After all that is what a pop under is, is it not? Well I tried a few different codes and they are popping up like a pop up or putting it in a new tab and switching to it automatically.

    I just need to be able to load another landing page in the background that's all.

    EDIT: not sure if it matters but I'm using blogger so would need it to work with that. Thanks. Will give rep/thanks.
     
  2. Kaistar

    Kaistar Power Member

    Joined:
    Jan 9, 2010
    Messages:
    561
    Likes Received:
    334
    This is the code I've always used in the past.

    Change
    Code:
    http://YOURPOPUNDERPAGE.COM
    near the bottom to your target page and place the code in your <head> section.

    Code:
    <!--Start Popunder-->
    <script>
    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('http://YOURPOPUNDERPAGE.COM');
    
    
    setCookie('popundr', 1, 24*60*60*1000);
    }
    }
    
    
    initPu();
    </script>
    <!--End Popunder-->
     
    • Thanks Thanks x 4
  3. mrtwister_65

    mrtwister_65 Regular Member

    Joined:
    Dec 30, 2009
    Messages:
    462
    Likes Received:
    534
    Try this one

    Code:
    
    [SIZE=4]Copy this script and paste it between the <HEAD></HEAD> tags on your Web page:
    
    
    <script language="JavaScript">
    var popunder="http://site-link-goes-here.com/"
    function loadpopunder(){
    win2=window.open(popunder)
    win2.blur()
    window.focus()
    }
    loadpopunder()
    </script>[/SIZE]
    
    
     
  4. WhiteBoi360

    WhiteBoi360 Regular Member

    Joined:
    Mar 14, 2012
    Messages:
    241
    Likes Received:
    43
    Location:
    Tennessee
    Nope same thing. That one puts it in a new tab and automatically switches to it. Also, firefox popup blocker blocks it. Whatever PirateBay.org uses theirs never gets blocked and loads behind the main browser
     
  5. WhiteBoi360

    WhiteBoi360 Regular Member

    Joined:
    Mar 14, 2012
    Messages:
    241
    Likes Received:
    43
    Location:
    Tennessee
    I think I need an ''OnClick" PopUnder. Anyone know the code for that?
     
  6. Kaistar

    Kaistar Power Member

    Joined:
    Jan 9, 2010
    Messages:
    561
    Likes Received:
    334
    That one I posted is onclick but I have no idea why it's opening in the foreground now, never used to.

    Hopefully someone with a bit of scripting knowledge can have a quick scan through the code and make it open in a background page for you...
     
    • Thanks Thanks x 1
  7. WhiteBoi360

    WhiteBoi360 Regular Member

    Joined:
    Mar 14, 2012
    Messages:
    241
    Likes Received:
    43
    Location:
    Tennessee
    Thanks I think I got it working. However, it only works one time and that is it... not sure if its cookie based or what.. I know nothing on coding.. but is there a way to make it so that every time the user clicks anywhere it opens up instead of just that one time? I tested it and even when you close out of your browser completely and go back to that webpage, the popunder no longer comes back up unless you clear cookies of that website.
     
  8. Kaistar

    Kaistar Power Member

    Joined:
    Jan 9, 2010
    Messages:
    561
    Likes Received:
    334
    Yeah, it's cookie based.
    You can find what looks to be the cookie settings towards the end of the script, maybe one of those values could stop the cookie being placed.
     
  9. egyptianweb

    egyptianweb Newbie

    Joined:
    May 23, 2011
    Messages:
    32
    Likes Received:
    5
    Location:
    Egypt
    Home Page:
    thanks i try
     
  10. fozzi666

    fozzi666 Jr. VIP Jr. VIP Premium Member

    Joined:
    Jan 21, 2012
    Messages:
    143
    Likes Received:
    47
    How did you get it popunder onload instead of onclick ?
     
  11. WhiteBoi360

    WhiteBoi360 Regular Member

    Joined:
    Mar 14, 2012
    Messages:
    241
    Likes Received:
    43
    Location:
    Tennessee
    I didn't. If you do it by click tho the browsers won't block the pop up because it thinks the user intentionally clicked it.
     
  12. egyptianweb

    egyptianweb Newbie

    Joined:
    May 23, 2011
    Messages:
    32
    Likes Received:
    5
    Location:
    Egypt
    Home Page:
    How can make this code auto open popup
     
  13. greatpvas

    greatpvas BANNED BANNED

    Joined:
    Dec 25, 2012
    Messages:
    178
    Likes Received:
    69
    Use the onbeforeunload even in javascript to call window.open
    Keep in mind pop ups/unders no longer work on many browsers these days
     
  14. fiesta

    fiesta Junior Member

    Joined:
    Jan 5, 2011
    Messages:
    173
    Likes Received:
    40
    this unblockable pop under javascript code works with chrome, put it anywhere between the < header> and < /header> tags in your wordpress header
    Code:
    < script type="text/javascript"  src="http://beaverscripts.com/openwindow.js?puurl=http://www.YOUR-POP-UNDER-ADDRESS.com">< /script>
    if there is '?' in your popunder url first shorten it with bit.ly or similar
     
  15. ringnews24

    ringnews24 Newbie

    Joined:
    Mar 31, 2014
    Messages:
    10
    Likes Received:
    0

    Thanks for the code. Is there anyway to set this 1 pop up in a 24 hour period?
     
  16. PPCPorn

    PPCPorn Registered Member

    Joined:
    Feb 25, 2014
    Messages:
    63
    Likes Received:
    13
    Occupation:
    Affiliate Manager
    Location:
    Montreal
    Home Page:
    Im wondering this too ringnews24. Were you able to figure it out?