如何在主窗口后面打开弹出窗口(HTML,jQuery)

时间:2012-11-20 21:39:28

标签: jquery html popup

我是新人。 我有一个弹出代码,当用户点击HTML页面中的任意位置时,会出现一个弹出窗口:

(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=/"

            }
        }
    }
})();

但弹出窗口位于顶部。是否可以在主页后面打开? 为此目的有没有更轻的弹出代码? 谢谢你们

1 个答案:

答案 0 :(得分:3)

你绝对不应该这样做。弹出广告具有侵略性和令人讨厌的特点。窗户下面偷偷打开窗户更加肮脏。

如果您不想打扰用户,请不要为您的广告使用任何类型的弹出窗口。

或者,您可以在现有页面中内嵌显示广告。

这样的弹出窗口很可能会被现代的浏览器阻挡。由于用户不希望看到这种行为,它们被阻止,这可能很危险。

不要制作隐藏的弹出式广告。