Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 检测弹出窗口阻止程序的使用_Javascript - Fatal编程技术网

Javascript 检测弹出窗口阻止程序的使用

Javascript 检测弹出窗口阻止程序的使用,javascript,Javascript,问题已解决 首先,我为我糟糕的英语道歉 我想检测客户端的浏览器是否阻止了弹出框。 我搜索了许多网站,并将许多答案整合到一个网站中。我的执行情况如下: var newWin = window.open("abc.html", "", "directories = no, height = 1000, width = 1000, menubar = no, resizable = no, scrollbars = no, status = no, titl

问题已解决

首先,我为我糟糕的英语道歉

我想检测客户端的浏览器是否阻止了弹出框。 我搜索了许多网站,并将许多答案整合到一个网站中。我的执行情况如下:

var newWin =       
    window.open("abc.html", "", 
    "directories = no, height = 1000, width = 1000, menubar = no, resizable = no, 
     scrollbars = no, status = no, titlebar = no, top = 0, location = no");
// alert true if the blocker is enabled
setTimeout( function() 
{
    if (!newWin || newWin.closed ||
        typeof newWin.closed == 'undefined' || newWin.outerHeight === 0)
        alert("true");
    else
    {
        alert("false");
    }, 25);
但是,并非所有浏览器都给出预期的响应

只有Firefox22、Safari 5.1.7和Opera 12给出了预期的响应

Chrome 27和IE 10没有给出预期的响应


有没有其他方法可以检测弹出窗口阻止程序?谢谢。

Chrome 27对我来说似乎很好,对我来说也很有用……但它在我的网站上不起作用=V=查找漏洞..不要使用弹出窗口,就这么简单。弹出窗口拦截器的存在正是因为这个原因,没有人想要弹出窗口。@Zachrip弹出窗口有时是必需的。例如,当用户位于您不希望强制导航离开的页面中,但希望警告他们挂起的超时。对于某些表单提交,也更易于使用以删除浏览器导航。这通常是为了防止他们使用后退按钮。作为程序员,我们知道即使我们告诉用户“不要使用XYZ按钮”,他们也不可避免地会这样做(我使用的是完全相同的逻辑,它适用于所有浏览器中的所有框,除了一个使用IE 11的框。不知道为什么。