JQuery security error in Opera and Internet Explorer

别等时光非礼了梦想. 提交于 2019-12-02 00:29:02

问题


I am developing an app for social network which works in IFrame. The app works just fine in Google Chrome and Microsoft Firefox browsers, but in Opera 12.15 JQuery library v1.10.1 fails to load with security error Unhandled error: Security error: attempted to read protected variable on line 1513.

The screenshot is here:

It looks like the same bug exists in Internet Explorer 10.

How to deal with it?

UPDATE:

I have made dirty hack by commenting the lines 1513-1517 in the code of jquery:

   // 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();
        });
    }*/

The functionality of my app seems to work now, maybe it is necessary to create issue in JQuery repo...


回答1:


Bug report was created - http://bugs.jquery.com/ticket/13980. Bug is now fixed.




回答2:


Add this before you include JQuery:

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

Hope it helps, It worked for me.



来源:https://stackoverflow.com/questions/16883663/jquery-security-error-in-opera-and-internet-explorer

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