【问题标题】:JQuery security error in Opera and Internet ExplorerOpera 和 Internet Explorer 中的 JQuery 安全错误
【发布时间】:2013-05-28 19:58:09
【问题描述】:

我正在为IFrame 开发一个社交网络应用程序。该应用在 Google Chrome 和 Microsoft Firefox 浏览器中运行良好,但在 Opera 12.15 JQuery 库 v1.10.1 中无法加载,并在 1513 行出现安全错误Unhandled error: Security error: attempted to read protected variable。

截图在这里:

Internet Explorer 10 中似乎存在相同的错误。

如何处理?

更新:

我通过在jquery 的代码中注释 1513-1517 行来进行肮脏的破解:

   // Support: IE>8
   // If iframe document is assigned to "document" variable and if iframe has been reloaded,
   // IE will throw "permission denied" error when accessing "document" variable, see jQuery #13936
  /*if ( parent && parent.frameElement ) {
        parent.attachEvent( "onbeforeunload", function() {
            setDocument();
        });
    }*/

我的应用程序的功能现在似乎可以工作了,也许有必要在 JQuery 存储库中创建问题...

【问题讨论】:

  • iframe 是否从同一个域加载内容?
  • @akonsu 不是,来自不同的
  • 也许这就是原因。尝试在使用相同域时访问它,看看它是否有效。
  • @akonsu 但是 FF 和 Chrome 工作得很好......
  • @akonsu 但我的应用程序在另一个域上,它正在加载到社交网络的 iframe 中

标签: javascript jquery internet-explorer opera


【解决方案1】:

已创建错误报告 - http://bugs.jquery.com/ticket/13980。 错误现已修复。

【解决方案2】:

在包含 JQuery 之前添加:

var isIE11 = !!(navigator.userAgent.match(/Trident/) && !navigator.userAgent.match(/MSIE/));
if (isIE11) {
    if (typeof window.attachEvent == "undefined" || !window.attachEvent) {
        window.attachEvent = window.addEventListener;
    }
}

希望它有所帮助,它对我有用。

【讨论】:

  • 这是 JQuery 中的一个真正的错误 - 请参阅已接受的答案。
猜你喜欢
  • 1970-01-01
  • 2018-07-11
  • 2020-05-29
  • 2012-05-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多