Permission denied on IE using window.open()?

∥☆過路亽.° 提交于 2019-12-02 02:19:47

问题


IE is giving me a permission denied error when I use window.open to open a window from a browser button. I do not get the error in Firefox or Chrome. What do I do?

The code:

<button type="button" onClick="window.open('https://www.example.com','newWindow');">
My button
</button>

回答1:


Are you running this from localhost or file://? If so, then that's indeed default behaviour. You could configure that away somewhere in the browser settings forest. But if you're actually running it from a real domain, then IE would in some cases emit this error as well when the URL points to a different domain. The browser security settings are apparently configured too strict. To fix this you would need to configure the browser settings accordingly.

This does however not remove the risk that one of your clients using IE would get the very same problem. If you insist in opening an external link in new window, I'd suggest to use an <a> with target="_blank" instead (although this attribute is deprecated in HTML; you could make it a rel="ext" and run some JS during onload to give a[rel=ext] the target attribute).



来源:https://stackoverflow.com/questions/2792069/permission-denied-on-ie-using-window-open

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!