jQuery issue in Internet Explorer 8
I am trying to get my jQuery functions to work on IE8. I am loading the library from Google's servers (http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js).
The $(function(){})
is never called. Instead, I get an error Object expected
. I opened the developer and ran typeof $
in the console, and it came up as undefined
.
I have tried going to other sites that I know use jQuery (jquery.com), and those all work, is there something I might be missing here?
Write "var" before variables, when you define them. IE8 dies when there is no "var".
Correction:
Check your script include tag, is it using
type="application/javascript" src="/path/to/jquery"
change to
type="text/javascript" src="/path/to/jquery"
I was having a similar issue. Things worked in IE6, Firefox, and IE8 running in IE7 compatibility mode; but not in 'normal' IE8. My solution was to put this code in the header
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
As to why jquery isn't working in IE8 I'm unclear.
The solution is to upgrade to the latest version of jQuery. I had the exact same problem and upgraded to 1.4.2 and it all works fine again in IE8.
Seems to be totally backwards-compatible with all the jQuery 1.3.2 stuff I did as well so no complaints here!