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:
<butto开发者_Go百科n type="button" onClick="window.open('https://www.example.com','newWindow');">
My button
</button>
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).
精彩评论