如何检测Chrome中的弹出式窗口拦截器? [英] How do I detect popup blocker in Chrome?

查看:229
本文介绍了如何检测Chrome中的弹出式窗口拦截器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在堆栈溢出中搜索了很多问题,可能是重复的 检测弹出窗口

I have searched many issue in stack overflow and might be duplicate here Detect Popup

对我没有帮助 Chrome中测试(测试v26.0.1410.64)

以下方法在IE和Firefox中工作 not in Chrome

But not helped for me while testing in Chrome (tested v26.0.1410.64)
Following Approach Worked in IE and Firefox but not in Chrome

var popup = window.open(winPath,winName,winFeature,true);
 if (!popup || popup.closed || typeof popup.closed=='undefined'){
       //Worked For IE and Firefox
        alert("Popup Blocker is enabled! Please add this site to your exception list.");
        window.location.href = 'warning.html';
 } else {
        //Popup Allowed
        window.open('','_self');
        window.close();
} 

任何适用于Chrome的更好解决方案也是?

Any better solution that works for Chrome also?

推荐答案

最后,通过结合Stackoverflow的成员

的不同答案获得成功此代码适用于我&在 IE,Chrome& Firefox

Finally, it success by combining different answer from Stackoverflow's member
This code worked for me & tested in IE, Chrome & Firefox

var popup = window.open(winPath,winName,winFeature,true);
 setTimeout( function() {
    if(!popup || popup.outerHeight === 0) {
        //First Checking Condition Works For IE & Firefox
        //Second Checking Condition Works For Chrome
        alert("Popup Blocker is enabled! Please add this site to your exception list.");
         window.location.href = 'warning.html';
    } else {
        //Popup Blocker Is Disabled
        window.open('','_self');
        window.close();
    } 
}, 25);

这篇关于如何检测Chrome中的弹出式窗口拦截器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆