This seems like an easy problem to solve, but it’s kickin my ass.
The following simple example produces an error in IE9. I’ve used IE9’s developer page to monitor network loading and it looks like IE is loading and executing the body’s script before the included javascript is loaded/evaluated.
I’ve tried all the various tricks found via searching for answers including adding <meta charset="UTF-8" /> and <meta http-equiv="x-ua-compatible" content="IE8"/>
<html>
<head>
<title>Demo of IE suckiness</title>
<script type='text/javascript'
src='http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js'></script>
</head>
<body>
This works in every browser but not IE9. IE gives the error:
<pre>
Line: 9
Error: The value of the property '$' is null or undefined, not a Function object
</pre>
<script type="text/javascript" defer="defer">
$(document).ready(function(){
alert("Must not be IE");
});
</script>
</body>
</html>
I have a work-around. Move the ready script to <body onload="ready()">, but I can’t believe this is broken for IE9, I must be doing something wrong and just can’t see it.
I had a similar problem. I fixed it by resetting all my IE9 settings.
I think by cranking up security or privacy it can break jquery loading from an external page.