IE10和jQuery:SCRIPT5009:“$”未定义 [英] IE10 and jQuery: SCRIPT5009: "$" is undefined

查看:1451
本文介绍了IE10和jQuery:SCRIPT5009:“$”未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了这个非常恼人的问题,它出现在IE10中,就像在IE9中一样。鉴于此HTML:

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>

这个(scripts.js)在FF和Chrome中工作正常,但是IE10会抛出SCRIPT5009错误。

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

scripts.js就像(简单但经过测试的例子):

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

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

IE10没有加载jQuery-File,我几乎尝试了所有东西。我更改并减少了文件名,我省去了

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]>...

部分,我试过了

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. 我应该如何为IE(10)命名jQuery-File?

  2. 我应该在哪里把脚本标签放在HTML-Header中?

非常感谢!

编辑:
这里建议的HTML版本也不起作用:

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是一个浏览器polyfill文件。

IE9.js is a browser polyfill file.

这是我的截图(ist undefiniert表示未定义,Die Webseite reagiert nicht表示页面已关闭,Debugger beenden表示停止调试,$('。aLang')是我的HTML中的一个类。

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.

推荐答案

我遇到了IE的这个问题,发现IE开发人员工具中的jQuery javascript文件已损坏。这是在我的情况下由HTTP GZIP压缩由服务器完成,但IE没有解压缩文件。我想如果你关闭静态HTTP压缩或从任何正在进行压缩的应用程序/ x-javascript中排除(我已完成通过FluorineFX获取超过10Kb的所有文件)一旦清除浏览器缓存以摆脱压缩的javascript文件,它应该可以正常工作。

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.

这篇关于IE10和jQuery:SCRIPT5009:“$”未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆