internet-explorer-8 - jQuery.noconflict() 显示“对象不支持此属性或方法”

标签 internet-explorer-8 mootools onload jquery

我的 jsp 以相同的顺序加载 Mootools、Jquery,然后加载我的 Javascript 文件。 在 IE8 中,首次加载时,会抛出错误“对象不支持此属性或方法”,并且 JS 根本不起作用。

我将 JSP 中的文件加载为:

new Asset.javascript('/js/jquery-1.6.4.min.js', {id: 'jQuery'});
new Asset.javascript('/js/MyScript.js', {id: 'CWScript'});

MyScript.js 如下所示:

jQuery.noConflict();
jQuery(document).ready(function(){ 
... 

它在 FF、IE6、Chrome 和 Safari 中工作正常,但在 IE8 中的 Line 1 Char 1 处中断

最佳答案

我不了解 Mootools,但对我来说,它看起来像是简单的竞争条件(假设 Assets 是异步加载的,并且没有任何指定的顺序执行)。尝试在 jQuery 加载资源的 onLoad 回调中加载 MyScript.js

并且,请记住 - 如果您使用 jQuery.noConfilct 我强烈建议使用此:

jQuery(document).ready(function($){
    //here you have local to jQuery under $ variable
});

关于internet-explorer-8 - jQuery.noconflict() 显示“对象不支持此属性或方法”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7412193/

相关文章:

jQuery 未加载且 '$' 在 IE8 中未定义

mootools - HTML - MOOTOOLS - 在 ie6 中添加选择框选项

不同浏览器中的 Javascript 滚动条类和鼠标滚轮速度

html - 寻找更好的方法来设置可调整大小的背景 Css3/HTML/mootools

javascript - 是什么导致 IE8 中的 Google map 错误?

internet-explorer-8 - 为什么IE8密码栏在键盘输入时什么都不显示?

css - IE 8背景图片问题

javascript - 仅在 IE 中 onload 时带有 appendChild 的 InvalidCharacterError

javascript - 如何为 SVG 图像元素实现延迟加载?

javascript - IE9 和 Iframe onload 事件