JQuery in iframe not working in IE

I have iframe content that includes jQuery and the jQuery part of the content in the iframe does not work in IE (the part that is not used by jQuery works fine and everything works fine in Chrome and Firefox).

Here is the code:

<!DOCTYPE html> <html> <head> <title>iframe content</title> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body> <h1>This heading is showing up just fine.</h1> <div id="jQuery-generated-content"> <!-- content dynamically generated by jQuery plugin This part is not showing in iframe in IE --> </div> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"> </script> <script src="pathTojQueryPlugin.js"></script> <script type="text/javascript"> jQuery.codeToInitiatePlugin </script> </body> </html> 

I tried to insert jQuery code in my head, right after the body tag, with both relative and absolute paths, but no luck. I would really appreciate if anyone knows of any workarounds for this or what causes IE not to read jQuery.

Thanks in advance!

+6
source share
4 answers

I also ran into the same problem a while ago. The problem is because IE cannot access the jquery library from the iframe and therefore cannot read jquery code. The only step is to convert jquery code to javascript.

Update:

Using a different version of jQuery may also solve the problem. Or another jQuery library may be used.

+5
source

From another SO question:

This is a legitimate jQuery 1.10.1 bug: http://bugs.jquery.com/ticket/13980 .

A source

In my case, using ...

 <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script> 

.. solved a problem. It was also the parent page version (thanks to Avigon).

+4
source

You may have already decided this differently, but in case someone else finds this message.

Here's a little trick that might help in some cases.
Add this inside the iframe before using jQuery:

 if (window.jQuery) { jQuery = window.jQuery; $ = window.jQuery; } 

However, the page containing the iframe must have jQuery. (And preferably the same version)

+3
source

The actual answer to this, as stated in the hotate17 comment in the comment, is that he / she downloaded the jQuery resource from the CDN, in this case the Google CDN. Downloading the jQuery resource from the same server and thus the same URL as the iFrame source fixed its problem and mine too, thanks hotate17!

http://www.sandiegosoftware.net/blog/script5-access-is-denied-error-in-internet-explorer-loading-jquery/

+3
source

Source: https://habr.com/ru/post/948413/


All Articles