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?
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="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js">
</script>
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.
I had a similiar issue with IE8. I find it so ironic that Microsoft is including JQuery in the latest versions of Visual Studio but their browser does not know how to interpret the javascript correctly. Here is some code (written by Stephen Walther is a Senior Program Manager at Microsoft) that will not run in IE8.... I downloaded and made Google Chrome my default browser and now my lightbox demo works great!. This is a very good tutorial on JQuery BTW - the link to the presentation is http://channel9.msdn.com/pdc2008/PC31/ and here is the code that IE8 chokes on
<script type="text/javascript">
var photoView;
function pageLoad()
{
$("#categories a").click(selectCategory);
photoView = $create(Sys.UI.DataView, {}, {}, {}, $get("photoContainer"));
}
function selectCategory(e)
{
// Stop link from executing
e.preventDefault();
// Highlight selected link
$("#categories a.selectedCategory").removeClass("selectedCategory");
$(this).addClass("selectedCategory");
// Invoke web service
PhotoServices.PhotoService.GetPhotos($(this).attr("categoryid"), getPhotosComplete);
}
function getPhotosComplete(photoData)
{
photoView.set_data(photoData);
$("#photoContainer").litebox();
}
</script>
I've run into this issue when trying to include jQuery from the CDN on a secure page. The weird thing was that it worked in every major browser EXCEPT ie8.
Write "var" before variables, when you define tehem. IE8 dies when there is no "var".
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
I had similar problems when trying to load jQuery from a script (by adding a script tag to the header) and calling it in the same script. Looked like some sort of timing issue, with jQuery not being loaded in time. I solved it by using putting a static script tag in the HTML code.
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!
I realize it's an old question, Having recently run into this issue myself, I wanted to ask if you were having issues while in HTTPS and inline scripts using jQuery ie $(document).ready(...)
?
In HTTPS it seems that IE8 attempts to interpret inline scripts before processing any external scripts.
My temporary fix/bandaid uses conditional tags for IE around the minified jQuery code inline on the page.
I'm going to attempt to move the suspected inline scripts to external script files as well to see if that does the trick.
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>
I had the same issue. The solution was to add the link to the JQuery file as a trusted site in IE.
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>
Similar problem. The site works fine on IE8, but when I iframe the site some pictures disappear and I get an access denied on jquery-1.3.min.js Works perfectly well on IE7, IE9 or FF3.6
There is another way to load jQuery from Google CDN (it uses google.load()
function) and according to this answer it works both in Firefox and Internet Explorer.