JQuery security error in Opera and Internet Explorer
Asked Answered
S

2

3

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:

Screenshot

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

Silo answered 2/6, 2013 at 14:24 Comment(13)
does the iframe load the contents from the same domain?Carnarvon
@Carnarvon not, from the differentSilo
maybe this is the reason then. try to access it when the same domain is used and see if it works.Carnarvon
@Carnarvon But FF and Chrome work very well...Silo
@Carnarvon but my application is on the other domain and it is loading in social network's iframeSilo
it's not the same bug as described above in comments for IE8? Insert breakpoint in debugger to error line and check variables.Pithos
@Pithos do you have a link to description?Silo
@zavg, bugs.jquery.com/ticket/13936Pithos
@Pithos in my case jquery is not loading at allSilo
@zavg, Сlear all private data in the Opera browser and check again.Pithos
@Pithos I have just downloaded it and used it only to test my app :)Silo
I can confirm the bug at jsfiddle: jsfiddle.net/SKfax (from the question jquery multi level accordion) - though that uses a very old jQuery versionKabob
@Kabob Maybe you write a comment on that issue with your jsfiddle link (bugs.jquery.com/ticket/13980)Silo
S
1

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

Silo answered 4/6, 2013 at 6:57 Comment(1)
P
0

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.

Poulenc answered 5/8, 2015 at 18:32 Comment(1)
It was a real bug in JQuery - please see the accepted answer.Silo

© 2022 - 2024 — McMap. All rights reserved.