Jquery抛出IE特定错误 [英] Jquery throws IE specific error

查看:128
本文介绍了Jquery抛出IE特定错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请参阅小提琴:

http:// jsfiddle。 net / JWSaZ /

这在Chrome / FF中工作正常,但在Internet Explorer中它在Jquery文件中出错:

This works fine in Chrome/FF, but in Internet Explorer it gives an error in the Jquery file:

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; Media Center PC 6.0; .NET CLR 3.5.30729; .NET CLR 3.0.30729)
Timestamp: Wed, 16 Feb 2011 23:59:13 UTC


Message: Unexpected call to method or property access.
Line: 16
Char: 55207
Code: 0
URI: https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js


推荐答案

你得到的错误是由于jQuery需要调用函数 resolveWith ,其中包含 try - finally ,不带 catch 阻止。在IE9之前,IE不支持这种情况并导致错误:

The error you're getting is due to jQuery needing to call the function resolveWith which contains a try - finally without a catch block. Until IE9, this is not supported by IE and causes the error:


对方法或属性
访问的意外调用。

Unexpected call to method or property access.

基本上,它发生在IE javascript引擎尝试进入finally块时。一个简单的解决方案是链接到您自己的jQuery源副本,并向此函数添加一个空的 catch 块。

Essentially, it happens when the IE javascript engine tries to enter the finally block. An easy solution would be to link to your own copy of the jQuery source and add an empty catch block to this function.

或者,如果您不必使用HTML5标记,请使用<$更改< construct> 标记c $ c>< p> 或带有id的div并更改你的jQuery选择器,你的问题应该消失,因为这个jQuery函数似乎没有被调用。请在此处查看IE8中示例的工作更新: http://jsfiddle.net/JWSaZ/21/

Alternately, if you do not have to use HTML5 markup, change your <construct> tags with <p> or a div with an id and change your jQuery selector and your issue should disappear since this jQuery function does not appear to be called. See a working update of your example in IE8 here: http://jsfiddle.net/JWSaZ/21/

这篇关于Jquery抛出IE特定错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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