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

Can you edit this pop under script?

Discussion in 'HTML & JavaScript' started by rap8557, Feb 4, 2013.

  1. rap8557

    rap8557 Jr. VIP Jr. VIP Premium Member

    Joined:
    Sep 15, 2008
    Messages:
    1,085
    Likes Received:
    436
    Just found a working pop up script. When you click the button it will redirect you on the a page you like at the same time it will open a pop up.

    How can i do this without a button? Onload and I need a rotation of pop up?

    Code:
    <!DOCTYPE html>
    <html>
    <head>
    <meta content="Hans-Peter Buniat" name="author">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Form-Submit Popunder</title>
    <script type="text/javascript" 
    
    src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
    </head>
    <body>
        <form id="testSubmit" action="http://www.google.com">
            <input type="submit" />
        </form>
     
        <script type="text/javascript">
        /* use jQuery as container for more convenience */
        (function($) {
            /**
             * Create a popunder
             *
             * @param  sUrl Url to open as popunder
             *
             * @return jQuery
             */
            $.popunder = function(sUrl) {
                var bSimple = $.browser.msie,
                    run = function() {
                        $.popunderHelper.open(sUrl, bSimple);
                    };
                (bSimple) ? run() : window.setTimeout(run, 1);
                return $;
            };
            
            /* several helper functions */
            $.popunderHelper = {
                /**
                 * Helper to create a (optionally) random value with prefix
                 *
                 * @param  string name
                 * @param  boolean rand
                 *
                 * @return string
                 */
                rand: function(name, rand) {
                    var p = (name) ? name : 'pu_';
                    return p + (rand === false ? '' : Math.floor(89999999*Math.random
    
    ()+10000000));
                },
                
                /**
                 * Open the popunder
                 *
                 * @param  string sUrl The URL to open
                 * @param  boolean bSimple Use the simple popunder
                 *
                 * @return boolean
                 */
                open: function(sUrl, bSimple) {
                    var _parent = self,
                        sToolbar = (!$.browser.webkit && (!$.browser.mozilla || 
    
    parseInt($.browser.version, 10) < 12)) ? 'yes' : 'no',
                        sOptions,
                        popunder;
                    
                    if (top != self) {
                        try {
                            if (top.document.location.toString()) {
                                _parent = top;
                            }
                        }
                        catch(err) { }
                    }
            
                    /* popunder options */
                    sOptions = 'toolbar=' + sToolbar + 
    
    ',scrollbars=yes,location=yes,statusbar=yes,menubar=no,resizable=1,width=' + 
    
    (screen.availWidth - 10).toString();
                    sOptions += ',height=' + (screen.availHeight - 122).toString() + 
    
    ',screenX=0,screenY=0,left=0,top=0';
            
                    /* create pop-up from parent context */
                    popunder = _parent.window.open(sUrl, $.popunderHelper.rand(), 
    
    sOptions);
                    if (popunder) {
                        popunder.blur();
                        if (bSimple) {
                            /* classic popunder, used for ie*/
                            window.focus();
                            try { opener.window.focus(); }
                            catch (err) { }
                        }
                        else {
                            /* popunder for e.g. ff4+, chrome */
                            popunder.init = function(e) {
                                with (e) {
                                    (function() {
                                        if (typeof window.mozPaintCount != 'undefined' 
    
    || typeof navigator.webkitGetUserMedia === "function") {
                                            var x = window.open('about:blank');
                                            x.close();
                                        }
            
                                        try { opener.window.focus(); }
                                        catch (err) { }
                                    })();
                                }
                            };
                            popunder.params = {
                                url: sUrl
                            };
                            popunder.init(popunder);
                        }
                    }
                    
                    return true;
                }
            };
        })(jQuery);
        
        $('#testSubmit').submit(function() {
            jQuery.popunder('http://www.fluege.de').popunder('http://www.flug24.de');
        });
        </script>
    </body>
    </html>
    
    
    Thanks
     
  2. Eightomic

    Eightomic Registered Member Premium Member

    Joined:
    Oct 20, 2012
    Messages:
    60
    Likes Received:
    13
    Occupation:
    Web Developer / Designer
    Location:
    United States
    Home Page:
    Try putting this before the ending </script> tag. How will the pop-unders be rotated? Randomly?

    Code:
    $(window).load(function() {
         jQuery.popunder('YOUR URL HERE').popunder('YOUR URL HERE');
    });
     
  3. bolgar89

    bolgar89 Newbie

    Joined:
    Jun 12, 2011
    Messages:
    2
    Likes Received:
    0
    It doesn't work when I change the url-s.
     
  4. inviz

    inviz Newbie

    Joined:
    Jun 15, 2010
    Messages:
    45
    Likes Received:
    5
    Eightomics approach is the right way to do it.. But your script gets detected by popup blockers..

    you could try:

    Code:
    $(document).ready(function() { 
        jQuery.popunder('http://www.fluege.de').popunder('http://www.flig24.de');
    )};
    
    But I'm pretty sure it would get blocked as well..
     
  5. prosper109

    prosper109 Junior Member

    Joined:
    Mar 3, 2013
    Messages:
    165
    Likes Received:
    12
    You can make a self-submitting form that clicks the button for you, and this form would auto submit during page visit


    <script type="text/javascript"> window.onload = function () { var form = document.getElementById("ognePaymentFrm"); form.submit(); };</script>