jQuery没有加载,IE8中未定义'$' [英] jQuery isn't loading and '$' is undefined in IE8
问题描述
我正在尝试用jQuery做一个非常基本的事情,它在IE8中根本不起作用,但在Firefox,Safari和Chrome中工作正常; IE一直给我一个预期的对象。
I am trying to do a very basic thing with jQuery, and it's not working at all in IE8 but works fine in Firefox, Safari and Chrome; IE gives me an "Object Expected" all the time.
任何人都可以帮忙吗?由于页面非常基本,我不确定是什么问题:
Can anyone help? I'm not sure what is wrong as the page is very basic:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.5.2.min.js"></script>
<script type="text/javascript">
$(function() {
alert("It works!");
});
</script>
</head>
<body>
</body>
</html>
IE(并且只有IE)在加载代码上给出了一个错误,说对象预期。我有IE开发工具栏和 $
未定义但在Firebug中它出现为功能。真的不知道是什么导致这个。
IE (and only IE) gives me an error saying "Object Expected" on the loading code. I have the IE Dev Toolbar and $
is undefined but in Firebug it comes up as "function". really don't know what is causing this.
推荐答案
好吧,我觉得自己像个白痴。我不知道如何(我当然没有改变它!)但不知何故我的IE禁用了JavaScript,所以难怪它不起作用!我可以帮助它时只使用FireFox。
Well, I feel like an idiot. I don't know how (I certainly didn't change it!) but somehow my IE was disabling JavaScript, so no wonder it was not working! I only use FireFox when I can help it.
这篇关于jQuery没有加载,IE8中未定义'$'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!