最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Permission denied on IE using window.open()? - Stack Overflow

programmeradmin0浏览0评论

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('','newWindow');">
My button
</button>

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.','newWindow');">
My button
</button>
Share Improve this question asked May 7, 2010 at 22:30 AlexAlex 66.1k49 gold badges153 silver badges181 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 4

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).

发布评论

评论列表(0)

  1. 暂无评论