如何测试命名的 window 是否打开或被弹出窗口阻止程序阻止?
How can I test if a named window is opened or was blocked by a popup blocker?
我正在使用以下代码在 javascript 中打开一个 window(实际上是 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 的弹出窗口阻止程序停止创建 window,我希望能够检测到并提醒用户。我可以在 win
上 运行 进行某种测试,看看它是否真的打开过?
如Window.open()所述:
How can I tell when my window was blocked by a popup blocker?
With the built-in popup blockers of Mozilla/Firefox and Internet Explorer 6 SP2, you have to check the return value of window.open(): it will be null if the window wasn't allowed to open. However, for most other popup blockers, there is no reliable way.
因此,如果 window.open 的 return 值为 null 或未定义,这意味着 window 被阻止。
我正在使用以下代码在 javascript 中打开一个 window(实际上是 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 的弹出窗口阻止程序停止创建 window,我希望能够检测到并提醒用户。我可以在 win
上 运行 进行某种测试,看看它是否真的打开过?
如Window.open()所述:
How can I tell when my window was blocked by a popup blocker?
With the built-in popup blockers of Mozilla/Firefox and Internet Explorer 6 SP2, you have to check the return value of window.open(): it will be null if the window wasn't allowed to open. However, for most other popup blockers, there is no reliable way.
因此,如果 window.open 的 return 值为 null 或未定义,这意味着 window 被阻止。