How to open popup behind main window (HTML,jQuery)

Posted by sara.ma on Stack Overflow See other posts from Stack Overflow or by sara.ma
Published on 2012-11-20T21:39:28Z Indexed on 2012/11/20 23:01 UTC
Read the original article Hit count: 201

Filed under:
|
|

I'm new. i have a popup code that when user click anywhere in the HTML page, a popup window shows up:

(function () {
    document.onclick = function () {

        var sUrl = "http://URL.com";

        if (typeof daily_capping == "undefined") var daily_capping = 10;

        if (typeof capping_minutes == "undefined") var capping_minutes = 60;

        if (document.cookie.indexOf("_popwin=") === -1) {

            var ads2day = document.cookie.split("_popwinDaily=")[1];

            ads2day = typeof ads2day == "undefined" ? 0 : parseInt(ads2day.split(";")[0]);

            if (ads2day < daily_capping) {

                var isMSIE = navigator.userAgent.indexOf("MSIE") != -1 ? !0 : !1,
                    _parent = self,
                    sOptions, popunder;

                if (top != self) try {
                    top.document.location.toString() && (_parent = top)
                } catch (err) {}

                sOptions = "toolbar=no,scrollbars=yes,location=yes,statusbar=yes,menubar=no,resizable=1,width=" + screen.width.toString() + ",height=" + (screen.height - 20).toString() + ",screenX=0,screenY=0,left=0,top=0", popunder = _parent.window.open(sUrl, "rhpop", sOptions);

                if (popunder) {
                    popunder.blur();
                    if (isMSIE) {
                        window.focus();
                        try {
                            opener.window.focus()
                        } catch (err) {}
                    } else popunder.init = function (e) {
                        with(e)(function () {
                            if (typeof window.mozPaintCount != "undefined" || typeof navigator.webkitGetUserMedia == "function") {
                                var e = window.open("about:blank");
                                e.close()
                            }
                            try {
                                opener.window.focus()
                            } catch (t) {}
                        })()
                    }, popunder.params = {
                        url: sUrl
                    }, popunder.init(popunder)
                }

                var now = new Date,
                    popDaily = (new Date(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate(), 23, 59, 59)).toGMTString();

                document.cookie = "_popwinDaily=" + (ads2day + 1) + ";expires=" + popDaily + ";path=/";

                var popInterval = new Date;
                popInterval.setTime(popInterval.getTime() + capping_minutes * 60 * 1e3), document.cookie = "_popwin=1;expires=" + popInterval.toGMTString() + ";path=/"

            }
        }
    }
})();

but popup is on top. is it possible to make it open behind main page?? is there any lighter popup code for this purpose? thanks guys

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about html