jQuery issue in Internet Explorer 8
JavascriptJqueryInternet Explorer-8Javascript Problem Overview
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?
Javascript Solutions
Solution 1 - Javascript
Write "var" before variables, when you define them. IE8 dies when there is no "var".
Solution 2 - Javascript
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"
Solution 3 - Javascript
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.
Solution 4 - Javascript
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!
Solution 5 - Javascript
I had this problem and tried the solutions mentioned here with no success.
Eventually, I realised that I was linking to the Google CDN version of the script using an http URL
while the page embedding the script was an https page
.
This caused IE to not load jquery (it prompts the user whether they want to load only secure content). Changing the Google CDN URL to use the https scheme fixed the problem for me.
Solution 6 - Javascript
Some people stumbling on this post might get this issue with jquery and IE8 because they're using >= jQuery v2. Use this code:
<!--[if lt IE 9]>
<script src="jquery-1.9.0.js"></script>
<![endif]-->
<!--[if gte IE 9]><!-->
<script src="jquery-2.0.0.js"></script>
<!--<![endif]-->
Solution 7 - Javascript
jQuery is not being loaded, this is not likely specific to IE8. Check the path on your jQuery include. statement. Or better yet, use the following to the CDN:
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js">
</script>
Solution 8 - Javascript
If you are using HTTPS on your site, you will need to load the jQuery library from Googles https server instead. Try this: https://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js (or the latest https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js)
Solution 9 - Javascript
I was fixing a template created by somebody else who forgot to include the doctype.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
If you don't declare the doctype
IE8 does strange things in Quirks mode.
Solution 10 - Javascript
The onload event does not always work on IE7/8 in <head> ... </head>
You can force it by adding an onload script at the end of your page before the tag as below.
<script>
window.onload();
</script>
</body>
Solution 11 - Javascript
The error Object expected
is raised because Jquery is not loaded. This happens because of browser security (usually IE) which does not allow you executing external javascript source code. You can correct this problem by:
- 1: Changing browser security level to allow executing external javascript code. You can find how to do this here
OR
- 2: Copy-paste the jquery source code into your web page so that it won't be considered as an external script.
I prefer the first solution.
Solution 12 - Javascript
I had the same problems.
I solved it verifying that IE8 was not configured correctly to reach the SRC URL.
I changed this, it works right.
Solution 13 - Javascript
Maybe you insert two scripts,it should be work.
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE8.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js">/script>
Solution 14 - Javascript
This fixed my issue in IE8:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
Running on localhost, I had to change the https:// to http://
If I try to browse to the secure link, I get the Internet Explorer cannot display the webpage friendly warning.
Always try to load your text scripts in a browswer first if there are issues!
Solution 15 - Javascript
Maybe you have inPrivate Filtering turned on?
Solution 16 - Javascript
I had the same issue. The solution was to add the link to the JQuery file as a trusted site in IE.
Solution 17 - Javascript
I think that you have same problem as I do:
Message: Permission denied
Line: 13
Char: 27021
Code: 0
URI: http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.3.2.min.js
Because of cross domain reference. Try to host jquery.js on same domain.
Solution 18 - Javascript
OK! I know that jQuery is loading. I know that jQuery.textshadow.js
is loading. I can find both of the scripts in Developer Tools.
The weird part: this code is working in the content area but not in the banner. Even with a dedicated fixIE.css
. AND it works when I put the css inline. (That, of course, messes up FireFox.)
I have even put in a conditional IE span around the text field in the banner with no luck.
I found no difference and had the same errors in both jquery-1.4.2.min.js
and jquery-1.2.6.min.js
. jquery.textshadow.js
was downloaded from the jQuery site while trying to find a solution to this problem.
This is not posted to the Website
Solution 19 - Javascript
In short, it's because of the IE8 parsing engine.
Guess why Microsoft has trouble working with the new HTML5 tags (like "section") too? It's because MS decided that they will not use regular XML parsing, like the rest of the world. Yes, that's right - they did a ton of propaganda on XML but in the end, they fall back on a "stupid" parsing engine looking for "known tags" and messing stuff up when something new comes around.
Same goes for IE8 and the jquery issue with "load", "get" and "post". Again, Microsoft decided to "walk their own path" with version 8. Hoping that they solve(d) this in IE9, the only current option is to fall back on IE7 parsing with <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
.
Oh well... what a surprise that Microsoft made us post stuff on forums again. ;)
Solution 20 - Javascript
The solution in my case was to take any special characters out of the URL you're trying to access. I had a tilde (~) and a percentage symbol in there, and the $.get() call failed silently.