My jQuery is not working with IE11
In my case I thought I had the fix with the compatability set in the meta tag.
<meta http-equiv="X-UA-Compatible" content="IE=edge;chrome=1" />
It worked, but that triggered me to check compatablity settting in IE11. For a previous project I had added localhost to the list in the Compatability View Settings.
Cleared the list and it works well now (without the meta tag).
user2660811
Updated on November 25, 2022Comments
-
user2660811 over 1 year
So I got three pieces of code to load stuff into div and do other things. But it doesn't work with Internet Explorer, I checked IE11 console and that's what I got
SCRIPT5009: '$' is undefined
That's odd, in every other browser it works fine, I tried to google it but didn't find any solution to this.
Here's my jQuery:
<script type="text/javascript"> $('#description').load('descr/portDefault.htm'); $('#portNav').load('menus/default.htm');
@edit
I guess I forgot to put the entire code, here it is: http://pastebin.com/xCL1e7Fh This html is an iframe in another html file if that makes a difference.
-
Tieson T. over 10 yearsWhere do you load the actual jQuery library?
-
jfriend00 over 10 yearsSo, obviously your IE11 is having trouble loading jQuery. You will have to give us some more clues as to what is going on before we'd have any idea why. Are you loading anything
async
ordefer
? Please include in your question the exact code that loads jQuery before you use it. Do you have any code that is doing$.noConflict()
. Are you using an jQuery plugins? Are there any other errors shown in the error console? -
user2660811 over 10 yearshere's the entire code pastebin.com/xCL1e7Fh
-
user2660811 over 10 yearsno other errors, just this one 3 times
-
Daved over 10 yearsDoes "jQuery" work? jQuery(document)
-
user2660811 over 10 yearswhat exactly do you mean Daved? There's one more error I ommited, sorry - SCRIPT438: Object doesn't support property or method 'attachEvent'
-
Daved over 10 years$ is just a shorthand reference to jQuery, the actual object. Instead of $('.myselector').click() you can do "jQuery('.myselector').click()". Does using "longhand" to call "jQuery" instead of "$" work? You can test in the console to reproduce errors.
-
user2660811 over 10 yearsStill doesn't work, now I only get this error "SCRIPT438: Object doesn't support property or method 'attachEvent'".
-
user2660811 over 10 yearsWhat is strange, if I open this html file directly in IE it works fine, but when I open main page where this file is an iframe it doesn't work.
-
Daved over 10 yearsI don't see an iframe in your code example. Is the jquery file being loaded in an iframe? And where is the script executing?
-
user2660811 over 10 yearsHere's the code of the main page: pastebin.com/m9x9kKXJ jQuery is being loaded both in main page and iframe. The first example code is an iframe itself.
-
user2660811 over 10 yearsFixed, IE is stupid as hell. All I had to do was to put the SAME src for jquery in main page and in iframe. My iframe page was in another folder so src paths were different which caused the problem, all I had to do is either move my iframes to the same folder as main page and change the src path to be the same, or change src path in iframe to the same as main page but copy jquery.js to the folder where my iframes are stored. That's confusing I know.
-
user2660811 over 10 yearsTL;DR - your path to jquery in main page and iframe must exactly THE SAME, it doesn't matter if it leads to same file but the path is different (src="jquery.js" in main page and src="../jquery.js in iframe) DUH!
-
Teemu over 10 years@user2660811 Notice, that
'attachEvent
is obsoleted in IE11.
-