Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
689 views
in Technique[技术] by (71.8m points)

internet explorer - IE10 and jQuery: SCRIPT5009: "$" is undefined

I'm faced with this really annoying problem, it appears in IE10 like in IE9. Given this HTML:

<head>
    <title>Any Consult</title>
    <meta charset="utf-8" />
    <link rel="stylesheet" type="text/css" href="styles.css" />
    <!--[if lte IE 9]>
        <script src="scripts/IE9.js"></script>
    <![endif]-->
    <script type="text/javascript" src="scripts/jquery.js"></script>
    <script type="text/javascript" src="scripts/scripts.js"></script>
</head>

This (scripts.js) works fine in FF and Chrome, but IE10 throws the SCRIPT5009 error.

scripts.js is like (simple, but tested example):

$(document).ready(function() {
   alert('Hello');
});

IE10 does not load the jQuery-File and I tried nearly everything. I changed and reduced the filename, I spared the

<!--[if lte IE 9]>...

part, I tried

src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.10.0.min.js"

but nothing happened. Because this is a new version of this question, I'd like to specify:

  1. how should I name the jQuery-File for IE(10)?
  2. where should I put the script tags in the HTML-Header?

Thanks a lot!

EDIT: Here the suggested HTML-version, which does not work, too:

<script type="text/javascript" src="scripts/jquery.js"></script>
<script type="text/javascript" src="scripts/scripts.js"></script>
<script type="text/javascript" src="scripts/clocks.js"></script>
<!--[if lte IE 9]>
    <script src="scripts/IE9.js"></script>
<![endif]-->
<!--[if IE]><script type="text/javascript" src="scripts/excanvas.js"></script><![endif]-->

IE9.js is a browser polyfill file.

And here is my screenshot ("ist undefiniert" means "is undefined", "Die Webseite reagiert nicht" means "the page went down", "Debugger beenden" means "stop debugging", $('.aLang') is a class in my HTML.

Screenshot IE10 Bug Report

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I had this problem with IE and found that the jQuery javascript file was corrupt in the IE developer tool. This was caused in my case by HTTP GZIP compression being done by the server but IE wasn't decompressing the file. I guess that if you turn off static HTTP compression or exclude the application/x-javascript from whatever is doing the compression (Mine was done by FluorineFX for all files over 10Kb) it should work okay once you have cleared your browser cache to get rid of the compressed javascript file.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

Just Browsing Browsing

[5] html - How to create even cell spacing within a

1.4m articles

1.4m replys

5 comments

57.0k users

...