如何处理ie8 jquery对象不支持此属性或方法错误?

时间:2022-05-03 05:30:02

This doesn't indicate any error in my javascript code, but in the downloaded jquery.js file, that is a renamed minified jquery 1.3.2 file.

这并不表示我的javascript代码中有任何错误,但在下载的jquery.js文件中,这是一个重命名的minified jquery 1.3.2文件。

I am testing some js code, in IE8 that works 100% in firefox and google chrome, before rolling it to production server.

我正在测试一些js代码,在IE8中,它在firefox和google chrome中100%工作,然后再将其转换为生产服务器。

But the jquery library itself seems to have issues inside IE8.

但是jquery库本身似乎在IE8中存在问题。

I even tried downloading a new copy of 1.3.2 jquery, and using that instead of the minified version, and it still errors out.

我甚至尝试下载1.3.2 jquery的新副本,并使用它而不是缩小版本,它仍然出错。

Then I tried using a the cdn hosted on at code.jquery.com, and it still errored out before even getting to letting my code work or not work.

然后我尝试使用在code.jquery.com上托管的cdn,它甚至在让我的代码工作或不工作之前仍然存在错误。

It appears to partially work in IE8, but other jquery on our dev server partially works, and keep's re-iterating, "Object doesn't support this property or method"

它似乎在IE8中部分工作,但我们的开发服务器上的其他jquery部分工作,并继续重复,“对象不支持此属性或方法”

Is there a specific version of jquery that works best in IE8? At least so I can see if there is an issue with my code or not in IE8?

是否有特定版本的jquery在IE8中效果最好?至少我可以在IE8中查看我的代码是否存在问题?

Or is there a list of jquery functions that don't work in IE8?

或者是否有一个在IE8中不起作用的jquery函数列表?

P.S. Also, I considered upgrading to IE9, to see if that had the same issue, but you can't download IE9, for WinXP, which sucks. I just like WinXP, and there's very little chance of upgrading. Before I had XP, I had Vista on my work pc, which really tanked.

附:此外,我考虑升级到IE9,看看是否有相同的问题,但你无法下载IE9,对于WinXP,这很糟糕。我只是喜欢WinXP,升级的可能性很小。在我使用XP之前,我在我的工作电脑上安装了Vista,这真的很糟糕。

Sorry for little vent, just trying to get this code working and error free...

对不起,小小的发泄,只是试图让这个代码工作,没有错误......

Thank You.


from comment

<!--- Include jQuery --->
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js" charset="utf-8"></script> 

8 个解决方案

#1


20  

I was getting this prob when I was using xxx.trim() instead of $.trim(xxx). Once I switched this prob went away.

当我使用xxx.trim()而不是$ .trim(xxx)时,我遇到了这个问题。一旦我换了这个问题就消失了。

#2


10  

Note: some may also arrive at this page by trying to use jQuery 2 with IE8. jQuery 2 drops support for IE8 (see: http://jquery.com/browser-support/).

注意:有些人也可能通过尝试在IE8中使用jQuery 2来到达此页面。 jQuery 2不再支持IE8(参见:http://jquery.com/browser-support/)。

If you need support for IE8, use the latest version of jQuery 1

如果需要IE8支持,请使用最新版本的jQuery 1

#3


3  

In my experience, jQuery is rarely the issue regardless of the version you might be running, what i typically do to get those nasty bugs out of the way, is to disable|remove any other javascript that you are running on the site (besides jquery), then start enabling 1 by 1 in conjunction with jquery, once you find where the error is hitting try to debug that script, 1 thing that has been really helpful in the past is to do jslint or jshint, if you are not familiar with those tools, they are tools that will help you validate your code and will recommend you improve some of your statements, based on previous developer experiences, JSLint is a more strict tool, i think JSHint will help you a little bit more as it is a little more forgiving in some aspects.

根据我的经验,jQuery很少出现问题,无论你运行的版本是什么,我通常做的就是把那些讨厌的错误排除在外,是禁用|删除你在网站上运行的任何其他javascript(除了jquery) ),然后与jquery一起开始一个接一个地启动,一旦找到错误发生的地方尝试调试该脚本,过去真正有用的一件事就是做jslint或jshint,如果你不熟悉的话这些工具,它们是帮助您验证代码的工具,并建议您根据以前的开发人员经验改进一些语句,JSLint是一个更严格的工具,我认为JSHint会帮助您更多一点,因为它是一个在某些方面更加宽容。

Let me know if that was helpful, also try to install IE8 Developer tools :)

让我知道,如果这是有帮助的,也尝试安装IE8开发工具:)

#4


2  

Basically there was a weird issue in my code, about declaring a variable.

基本上我的代码中有一个奇怪的问题,关于声明一个变量。

So this had nothing to do with jquery loading, but it wouldn't in any way show an error message related to a line in my code.

所以这与jquery加载无关,但它不会以任何方式显示与我的代码中的一行相关的错误消息。

As soon as I declared the variable above the logic, it worked, error free.

一旦我将变量声明为逻辑之上,它就可以正常运行。

Thanks to everyone for trying.

感谢大家的努力。

#5


0  

It could be many reasons but I was facing the same error and I was using

这可能有很多原因,但我遇到了同样的错误而且我正在使用

.html().trim();

when I changed it to

当我改变它

.html()+""; 

it resolved the issue. check the error line and if you are using .trim() after .html(), remove it.

它解决了这个问题。检查错误行,如果在.html()之后使用.trim(),则将其删除。

#6


0  

I was experiencing the sames issue, in my case was caused by chaining trim() onto text() functions in ie8

我遇到了同样的问题,在我的情况下是由于将trim()链接到ie8中的text()函数引起的

Offending Code was $("td:eq(n)", this).text().trim();

违规代码是$(“td:eq(n)”,this).text()。trim();

Changed to: $.trim(("td:eq(n)", this).text());

更改为:$ .trim((“td:eq(n)”,this).text());

Now working.

#7


0  

I had this issue with a variable called form changing that tiny thing fixed it.

我有一个名为form的变量这个问题,改变了那个很小的东西。

#8


0  

This will also happen if you are trying to use ES5 .bind on a callback with your jquery.

如果您尝试在jquery的回调中使用ES5 .bind,也会发生这种情况。

$('#ref').on('click', function() { 
    // do stuff 
}.bind(this));

#1


20  

I was getting this prob when I was using xxx.trim() instead of $.trim(xxx). Once I switched this prob went away.

当我使用xxx.trim()而不是$ .trim(xxx)时,我遇到了这个问题。一旦我换了这个问题就消失了。

#2


10  

Note: some may also arrive at this page by trying to use jQuery 2 with IE8. jQuery 2 drops support for IE8 (see: http://jquery.com/browser-support/).

注意:有些人也可能通过尝试在IE8中使用jQuery 2来到达此页面。 jQuery 2不再支持IE8(参见:http://jquery.com/browser-support/)。

If you need support for IE8, use the latest version of jQuery 1

如果需要IE8支持,请使用最新版本的jQuery 1

#3


3  

In my experience, jQuery is rarely the issue regardless of the version you might be running, what i typically do to get those nasty bugs out of the way, is to disable|remove any other javascript that you are running on the site (besides jquery), then start enabling 1 by 1 in conjunction with jquery, once you find where the error is hitting try to debug that script, 1 thing that has been really helpful in the past is to do jslint or jshint, if you are not familiar with those tools, they are tools that will help you validate your code and will recommend you improve some of your statements, based on previous developer experiences, JSLint is a more strict tool, i think JSHint will help you a little bit more as it is a little more forgiving in some aspects.

根据我的经验,jQuery很少出现问题,无论你运行的版本是什么,我通常做的就是把那些讨厌的错误排除在外,是禁用|删除你在网站上运行的任何其他javascript(除了jquery) ),然后与jquery一起开始一个接一个地启动,一旦找到错误发生的地方尝试调试该脚本,过去真正有用的一件事就是做jslint或jshint,如果你不熟悉的话这些工具,它们是帮助您验证代码的工具,并建议您根据以前的开发人员经验改进一些语句,JSLint是一个更严格的工具,我认为JSHint会帮助您更多一点,因为它是一个在某些方面更加宽容。

Let me know if that was helpful, also try to install IE8 Developer tools :)

让我知道,如果这是有帮助的,也尝试安装IE8开发工具:)

#4


2  

Basically there was a weird issue in my code, about declaring a variable.

基本上我的代码中有一个奇怪的问题,关于声明一个变量。

So this had nothing to do with jquery loading, but it wouldn't in any way show an error message related to a line in my code.

所以这与jquery加载无关,但它不会以任何方式显示与我的代码中的一行相关的错误消息。

As soon as I declared the variable above the logic, it worked, error free.

一旦我将变量声明为逻辑之上,它就可以正常运行。

Thanks to everyone for trying.

感谢大家的努力。

#5


0  

It could be many reasons but I was facing the same error and I was using

这可能有很多原因,但我遇到了同样的错误而且我正在使用

.html().trim();

when I changed it to

当我改变它

.html()+""; 

it resolved the issue. check the error line and if you are using .trim() after .html(), remove it.

它解决了这个问题。检查错误行,如果在.html()之后使用.trim(),则将其删除。

#6


0  

I was experiencing the sames issue, in my case was caused by chaining trim() onto text() functions in ie8

我遇到了同样的问题,在我的情况下是由于将trim()链接到ie8中的text()函数引起的

Offending Code was $("td:eq(n)", this).text().trim();

违规代码是$(“td:eq(n)”,this).text()。trim();

Changed to: $.trim(("td:eq(n)", this).text());

更改为:$ .trim((“td:eq(n)”,this).text());

Now working.

#7


0  

I had this issue with a variable called form changing that tiny thing fixed it.

我有一个名为form的变量这个问题,改变了那个很小的东西。

#8


0  

This will also happen if you are trying to use ES5 .bind on a callback with your jquery.

如果您尝试在jquery的回调中使用ES5 .bind,也会发生这种情况。

$('#ref').on('click', function() { 
    // do stuff 
}.bind(this));