0

我正在使用以下代码在javascript中打开一个窗口(实际上是PayPal):

win = window.open('', this.name, 'top=' + top + ', left=' + left + 
  ', width=' + width + ', height=' + height + 
  ', location=0, status=0, toolbar=0, menubar=0, resizable=0, scrollbars=1');

如果 Chrome 的弹出窗口阻止程序停止创建窗口,我希望能够检测到并提醒用户。是否有某种测试我可以运行win以查看它是否真的打开过?

4

1 回答 1

1

Window.open()中所述:

如何判断我的窗口何时被弹出窗口阻止程序阻止?

使用 Mozilla/Firefox 和 Internet Explorer 6 SP2 的内置弹出窗口阻止程序,您必须检查 window.open() 的返回值:如果不允许打开窗口,它将为 null。但是,对于大多数其他弹出窗口阻止程序,没有可靠的方法。

因此,如果 window.open 的返回值为 null 或 undefined,这意味着窗口被阻塞。

于 2016-07-31T18:20:27.183 回答