IE中出现奇怪的jQuery错误:意外调用方法或属性 [英] Strange jQuery error in IE: Unexpected call to method or property access

查看:94
本文介绍了IE中出现奇怪的jQuery错误:意外调用方法或属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无论如何,在Firefox,Chrome,Safari和Opera中,一切正常.但是IE ...这是另一个故事:)

Like allways, in Firefox, Chrome, Safari and Opera everything works without a problem. But IE... This is another story :)

这是我的完整代码: http://pastebin.com/ZdzzFayJ

在IE中至少有一件好事,出现以下错误:

At least one thing good in IE, come to me with the following error:

SCRIPT65535: Unexpected call to method or property access. 
jquery.min.js, line 3 character 29586

怎么了?我找不到错误:(

What is wrong? I can't find a bug :(

更新

我清理了代码,现在将javascript函数称为jQuery插件.我仍然遇到错误,但现在我知道在哪里.

I cleaned up my code, javascript functions are now called as a jQuery plugin. I am still getting an error, but now I know where.

在我的代码中,我在IE提醒错误消息的代码旁边添加了注释IE ERROR.

In my code I put a comment IE ERROR next to the code where IE alert the error message.

插件: http://pastebin.com/6Dnd1qtd

jQuery: http://pastebin.com/wiHALjZx

我不知道为什么IE会在那里中断.任何解决方案吗?

I have no idea why IE breaks there.. Any solutions?

关于马里奥

推荐答案

我通过以下方式解决了这个问题:

I solved the problem in the following way:

  • 清理我的代码( JSHint 很有帮助!)
  • 在将"//html5shiv.googlecode.com/svn/trunk/html5.js"包含到IE中之前,我先意识到我正在使用HTML5标签,例如节,标题,...
  • 在jQuery插件中,我用html内容填充了元素.我使用的是defaultOpts.data_container.html("HTML CONTENT"),而不是使用$(defaultOpts.data_container).html("HTML CONTENT").因此,我将对象元素$(#ID)作为参数发送给插件,而不是仅发送元素ID "#ID".
  • Clean up my code ( JSHint was very helpful! )
  • Before anything I included "//html5shiv.googlecode.com/svn/trunk/html5.js" to IE recognize that I am using HTML5 tags such as section, header,...
  • In jQuery plugin I fill element with html content. Instead of using $(defaultOpts.data_container).html("HTML CONTENT") I use defaultOpts.data_container.html("HTML CONTENT"). So I send object element $(#ID) in parameter to plugin instead of sending just element ID "#ID".

现在,一切正常.谢谢大家的支持和努力.

Now, everything working OK. Thank you all for your support and effort.

这篇关于IE中出现奇怪的jQuery错误:意外调用方法或属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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