javascript IE8 上的 jquery(null 为 null 或不是对象)错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9879878/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
jquery (null is null or not an object) error on IE8
提问by C0D3
When I load jquery using:
当我使用以下方法加载 jquery 时:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
it works on IE9, firefox, chrome, safari but not IE8. I tried the developer/debugger tools but still don't understand why this is an issue.
它适用于 IE9、firefox、chrome、safari,但不适用于 IE8。我尝试了开发人员/调试器工具,但仍然不明白为什么这是一个问题。
This is the character code jquery supposedly has error on: 32039.
On that line there is such function:
这是字符代码 jquery 据说有错误:32039。
在那一行有这样的功能:
G=function(a){
var b=F.exec(a);
b&&(b[1]=(b[1]||"").toLowerCase(),b[3]=b[3]&&new RegExp("(?:^|\s)"+b[3]+"(?:\s|$)"));
return b
}
Anyone came across this issue as well?
有人也遇到过这个问题吗?
The site is http://www.kanersan.com
I am not calling jquery before it is loaded and I'm loading it inside the head tag.
我没有在加载之前调用 jquery,而是将它加载到 head 标签中。
采纳答案by Nenad
This is a bug in jQuery 1.7.1 when used with SyntaxHighlighter
当与 SyntaxHighlighter 一起使用时,这是 jQuery 1.7.1 中的一个错误
http://bugs.jquery.com/ticket/10961
http://bugs.jquery.com/ticket/10961
So you have to upgrade jQuery to 1.7.2 and everything will be working fine.
所以你必须将 jQuery 升级到 1.7.2,一切都会正常工作。
回答by Javascript Coder
try to folow some steps:-
尝试遵循一些步骤:-
1.jQuery is not being loaded, this is not likely specific to IE8. Check the path on your jQuery include. statement. Or better yet,.. TRy to give direct path.
1.jQuery 没有被加载,这可能不是 IE8 特有的。检查 jQuery 包含的路径。陈述。或者更好的是,.. 尝试给出直接路径。
2.May be because of compatibility issue.. Try to give compatibility solutions.. 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
2.可能是因为兼容性问题。。尝试给出兼容性解决方案。在IE7兼容模式下运行的IE6,Firefox和IE8下工作正常;但不是在“正常”的 IE8 中。我的解决方案是将此代码放在标题中
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
As to why jquery isn't working in IE8 I'm unclear.
至于为什么 jquery 在 IE8 中不起作用,我不清楚。
3.Try to load your jquery on window load.
3. 尝试在窗口加载时加载您的 jquery。
4.Try to define your jquery file in top..
4.尝试在顶部定义您的jquery文件..
5.Very important point - try to check your html and jquery code.. IE is very sensetive for code.. so cross check your Html code ,... Is everything is fine..
5.非常重要的一点 - 尝试检查你的 html 和 jquery 代码.. IE 对代码非常敏感.. 所以交叉检查你的 Html 代码,.. 一切都很好..
6.Changing browser sercurity level to allow executing external javascript code.
6.更改浏览器安全级别以允许执行外部javascript代码。
7.Replicate javascript framwork..
7.复制javascript框架..
May this will help You !!!!!!!!1
愿这会帮助你!!!!!!!!!1
回答by Rafferty
Some things worth trying...
有些东西值得尝试...
Remove
type="text/javascript"
like so:<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
Make sure you reference
jquery.min.js
beforeyour javascript code that uses jQuery.
type="text/javascript"
像这样删除:<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
确保
jquery.min.js
在使用 jQuery 的 javascript 代码之前引用。
Most probably, the above suggestions will not help, but since the problem sounds IE8 specific, I believe it's worth a try doing some trivial things that might solve the problem.
最有可能的是,上述建议无济于事,但由于问题听起来是 IE8 特有的,我相信值得尝试做一些可能解决问题的琐碎事情。