javascript window.open(....) 在某些浏览器中被阻止
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9616150/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
window.open(....) getting blocked in some browsers
提问by Manoj Hipparagi
I have a script where it opens a window for online application after executing some other scripts.
我有一个脚本,它在执行其他一些脚本后打开一个用于在线应用程序的窗口。
window.open()
is not called on any click. It is getting called in a script and browser prevents the new window from appearing.
window.open()
不会在任何点击时调用。它在脚本中被调用,浏览器会阻止新窗口出现。
How to overcome this?
如何克服这一点?
here is the code..
这是代码..
window.open('/search/applyonline?jobid=".$jobDetails->getIdjob()."',
'applyurljob',
'height=550,\
width=800,\
toolbar=no,\
directories=no,\
status=no,\
menubar=no,\
scrollbars=yes,\
resizable=yes,\
left=200,\
top=250')
回答by Tim Rogers
Popup blockers will block windows from being opened that are not in response to a click event. Therefore you can:
弹出窗口阻止程序将阻止打开未响应单击事件的窗口。因此,您可以:
- Ask your users to turn off their popup blocker (not nice).
- Change your scripts to work in response to a link or button click.
- Use fake windows such as a jQuery UI dialog.
- 要求您的用户关闭他们的弹出窗口阻止程序(不好)。
- 更改您的脚本以响应链接或按钮单击。
- 使用伪窗口,例如jQuery UI 对话框。