使用window.open()在IE上拒绝权限? [英] Permission denied on IE using window.open()?

查看:247
本文介绍了使用window.open()在IE上拒绝权限?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用window.open从浏览器按钮打开一个窗口时,IE给我一个权限被拒绝的错误.我没有在Firefox或Chrome浏览器中收到错误消息.我该怎么办?

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?

代码:

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

推荐答案

您是从localhost还是file://运行此程序?如果是这样,那确实是默认行为.您可以在浏览器设置林中的某个位置进行配置.但是,如果您实际上是从真实域中运行它,则在URL指向不同域时,IE在某些情况下也会发出此错误.浏览器安全设置显然配置得太严格.要解决此问题,您需要相应地配置浏览器设置.

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.

但是,这不能消除使用IE的客户之一遇到同样问题的风险.如果您坚持要在新窗口中打开外部链接,我建议使用<a>target="_blank"代替(尽管此属性在HTML中已弃用;您可以将其设置为rel="ext"并在onload期间运行一些JS赋予a[rel=ext]目标属性).

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

这篇关于使用window.open()在IE上拒绝权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆