SCRIPT5009: "$" - undefined in IE9

I have a bookmarklet that loads a div into the current page and places an iframe inside it. This bookmarklet works like a dream in all browsers except IE9. Even works in earlier versions of IE.

I use the following bookmarklet structure:

http://idc.anavallasuiza.com/project/bookmarklets 

Someone else had a similar problem (not related to bookmarklets):

 https://forum.jquery.com/topic/retrieved-html-data-type-with-jquery-ajax-in-ie9-scripts-tags-sources-could-not-be-loaded 

So far, I understand that my jQuery bookmarklet does not load correctly in IE9.

The bookmarklet attempts to load its own jQuery, so certain effects can be triggered when the bookmarklet is initialized and programming is easy.

The iFrame page also loads jQuery (without it, the contents in the iframe do not work properly).

I am using the latest jQuery:

 http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js 

I would like to know why IE9 causes these SCRIPT errors when another browser is down? Why is jQuery not loading properly in IE9?

Any insight would be greatly appreciated.

+6
source share
2 answers

I just spent a few hours struggling with this problem and finally found a solution that I think will help you.

Here is a simplified version of the code that caused problems for me:

 $frames = $(*html_including_frames_here*); $div = $('<div></div>'); $div.append($frames); $('body').append($div); 

** Loading one or more frames into divs that are NOT in the DOM and THEN; loading this div into the DOM causes all problems in my cases. Frames do not load JS scripts as they should, and then all (jQuery, JSON, etc.) are undefined.

This, on the other hand, works:

 $frames = $(*html_including_frames_here*); $div = $('<div></div>'); $('body').append($div); $div.append($frames); 

The only difference here is that I first put the div in the dom, and THEN loads the frames into it. One way or another, it matters.

+6
source

Thanks for your question, I had the same problem. the first time I fixed it by downloading jquery from jquery.com ( http://code.jquery.com/jquery-1.7.1.js ). then IE9 loads it. maybe Microsoft is blocking some google-apis? very interesting...

+1
source

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


All Articles