无法检查弹出窗口阻止程序是否在chrome中启用

时间:2013-04-23 10:38:53

标签: javascript popup

我在JavaScript中编写以下代码,我无法检查是否在chrome中启用了弹出窗口阻止程序

方法1:

var params = 'height=1,width=1,left=-100,top=-100,location=no,toolbar=no,menubar=no,scrollbars=no,resizable=no,directories=no,status=no';
var testWindow = window.open(null, "popupTest", params);
if( !testWindow
    || testWindow.closed
    || (typeof testWindow.closed=='undefined')
    || testWindow.outerHeight == 0
    || testWindow.outerWidth == 0
    ) {
    // pop-ups ARE blocked
  //  document.location.href = 'popupsBlocked.htm';
    alert("blocked");
}
else {
    // pop-ups are NOT blocked
  testWindow.close();
    alert("not blocked");
}

方法2:

var test = window.open(null, "", "width=0,height=0");
    try {
        test.close();           
        alert("Pop-ups not blocked");
    } catch (e) {
        alert("Pop-up blocker is enabled in the browsers");
    }

两种方法都不起作用请帮帮我....

0 个答案:

没有答案