ie 8中的jQuery问题

时间:2021-11-07 17:16:33

I am trying to get my jQuery functions to work on IE8. I am loading the library from Google's servers (http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js).

我正在尝试使用jQuery函数来处理IE8。我正在从谷歌的服务器(http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js)加载库。

The $(function(){}) is never called. Instead, I get an error Object expected. I opened the developer and ran typeof $ in the console, and it came up as undefined.

从来不会调用$(function(){})。相反,我得到一个预期的错误对象。我打开了开发人员并在控制台中运行了$ $,结果是未定义的。

I have tried going to other sites that I know use jQuery (jquery.com), and those all work, is there something I might be missing here?

我尝试去其他我知道使用jQuery的网站(jquery.com),这些都是有用的,我可能在这里遗漏了什么?

20 个解决方案

#1


42  

Write "var" before variables, when you define them. IE8 dies when there is no "var".

在定义变量之前写“var”。IE8在没有“var”时就会死。

#2


39  

Correction:

更正:

Check your script include tag, is it using

检查你的脚本是否包含标签,是否使用

type="application/javascript" src="/path/to/jquery" 

change to

改变

type="text/javascript" src="/path/to/jquery" 

#3


38  

I was having a similar issue. 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

我也有类似的问题。在IE6、Firefox和IE8中工作的东西在IE7兼容模式下运行;但在“正常”的IE8中却不是这样。我的解决方案是把这段代码放到header中

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /> 

As to why jquery isn't working in IE8 I'm unclear.

至于jquery为什么不在IE8中工作,我不清楚。

#4


12  

The solution is to upgrade to the latest version of jQuery. I had the exact same problem and upgraded to 1.4.2 and it all works fine again in IE8.

解决方案是升级到最新版本的jQuery。我也遇到了同样的问题,并将其升级为1.4.2,这在IE8中再次运行良好。

Seems to be totally backwards-compatible with all the jQuery 1.3.2 stuff I did as well so no complaints here!

似乎完全向后兼容所有jQuery 1.3.2,所以这里没有抱怨!

#5


10  

I had this problem and tried the solutions mentioned here with no success.

我遇到了这个问题,尝试了这里提到的解决方法,但没有成功。

Eventually, I realised that I was linking to the Google CDN version of the script using an http URL while the page embedding the script was an https page.

最后,我意识到我正在使用http URL链接到该脚本的谷歌CDN版本,而嵌入该脚本的页面是https页面。

This caused IE to not load jquery (it prompts the user whether they want to load only secure content). Changing the Google CDN URL to use the https scheme fixed the problem for me.

这导致IE不加载jquery(提示用户是否只加载安全内容)。更改谷歌CDN URL以使用https方案解决了我的问题。

#6


8  

Some people stumbling on this post might get this issue with jquery and IE8 because they're using >= jQuery v2. Use this code:

有些人在这篇文章中偶然发现了jquery和IE8的问题,因为他们使用的是>= jquery v2。使用这段代码:

<!--[if lt IE 9]>    <script src="jquery-1.9.0.js"></script><![endif]--><!--[if gte IE 9]><!-->    <script src="jquery-2.0.0.js"></script><!--<![endif]-->

#7


6  

If you are using HTTPS on your site, you will need to load the jQuery library from Googles https server instead. Try this:https://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js(or the latest https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js)

如果在站点上使用HTTPS,则需要从google HTTPS服务器加载jQuery库。试试这个:https://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js(或者最新的https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js)

#8


6  

jQuery is not being loaded, this is not likely specific to IE8. Check the path on your jQuery include. statement. Or better yet, use the following to the CDN:

jQuery没有被加载,这不是IE8特有的。检查jQuery包含的路径。声明。或者更好的是,对CDN使用以下内容:

<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"></script>

#9


5  

I was fixing a template created by somebody else who forgot to include the doctype.

我正在修复一个由其他人创建的模板,这个模板忘记包含doctype。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

If you don't declare the doctype IE8 does strange things in Quirks mode.

如果你不声明doctype IE8,它会以奇怪的方式做一些奇怪的事情。

#10


4  

The error Object expected is raised because Jquery is not loaded. This happens because of browser security (usually IE) which does not allow you executing external javascript source code. You can correct this problem by:

由于未加载Jquery,因此将引发预期的错误对象。这是因为浏览器安全性(通常是IE)不允许执行外部javascript源代码。你可以通过:

  • 1: Changing browser security level to allow executing external javascript code. You can find how to do this here
  • 1:更改浏览器安全级别,允许执行外部javascript代码。你可以在这里找到方法。

OR

  • 2: Copy-paste the jquery source code into your web page so that it won't be considered as an external script.
  • 2:将jquery源代码复制到web页面中,这样就不会将其视为外部脚本。

I prefer the first solution.

我喜欢第一种解决办法。

#11


4  

The onload event does not always work on IE7/8 in <head> ... </head>

onload事件并不总是在中对IE7/8起作用…< / >头

You can force it by adding an onload script at the end of your page before the tag as below.

您可以通过在标签前面的页面末尾添加onload脚本来强制执行,如下所示。

  <script>    window.onload();  </script></body>

#12


2  

Maybe you insert two scripts,it should be work.

也许你插入了两个脚本,应该没问题。

<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE8.js"></script>  <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js">/script> 

#13


2  

This fixed my issue in IE8:

这修正了我在IE8中的问题:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>

Running on localhost, I had to change the https:// to http://

在本地主机上运行时,我必须将https://更改为http://

If I try to browse to the secure link, I get the Internet Explorer cannot display the webpagefriendly warning.

如果我尝试浏览安全链接,我得到Internet Explorer不能显示网页友好的警告。

Always try to load your text scripts in a browswer first if there are issues!

如果有问题,一定要先在浏览器中加载文本脚本!

#14


2  

I had the same problems.

我也有同样的问题。

I solved it verifying that IE8 was not configured correctly to reach the SRC URL.

我解决了它验证IE8没有正确配置以到达SRC URL。

I changed this, it works right.

我改变了这个,它是正确的。

#15


1  

Maybe you have inPrivate Filtering turned on?

也许你打开了inPrivate过滤?

#16


1  

I had the same issue. The solution was to add the link to the JQuery file as a trusted site in IE.

我有同样的问题。解决方案是将JQuery文件的链接添加到IE中的受信任站点。

#17


1  

I think that you have same problem as I do:

我认为你和我有同样的问题:

Message: Permission deniedLine: 13Char: 27021Code: 0URI: http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.3.2.min.js

Because of cross domain reference. Try to host jquery.js on same domain.

因为交叉域引用。主机jquery。js在相同的域。

#18


0  

In short, it's because of the IE8 parsing engine.

简而言之,这是因为IE8解析引擎。

Guess why Microsoft has trouble working with the new HTML5 tags (like "section") too? It's because MS decided that they will not use regular XML parsing, like the rest of the world. Yes, that's right - they did a ton of propaganda on XML but in the end, they fall back on a "stupid" parsing engine looking for "known tags" and messing stuff up when something new comes around.

猜猜为什么微软在处理新的HTML5标签时遇到了麻烦(比如“section”)?这是因为MS决定不使用常规的XML解析,就像世界其他地方一样。是的,没错——他们在XML上做了大量宣传,但最终,他们求助于一个寻找“已知标记”的“愚蠢”解析引擎,并在出现新东西时把东西搞得一团糟。

Same goes for IE8 and the jquery issue with "load", "get" and "post". Again, Microsoft decided to "walk their own path" with version 8. Hoping that they solve(d) this in IE9, the only current option is to fall back on IE7 parsing with <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />.

IE8和jquery关于“load”、“get”和“post”的问题也是如此。再次,微软决定“走自己的路”与版本8。希望在IE9中解决这个问题(d),目前唯一的选择是使用 进行IE7解析。

Oh well... what a surprise that Microsoft made us post stuff on forums again. ;)

哦……微软又让我们在论坛上发东西,真是令人惊讶。,)

#19


0  

The solution in my case was to take any special characters out of the URL you're trying to access. I had a tilde (~) and a percentage symbol in there, and the $.get() call failed silently.

在我的例子中,解决方案是从要访问的URL中取出任何特殊字符。我有一个波浪符号(~)和一个百分比符号,$.get()调用静默失败。

#20


0  

OK! I know that jQuery is loading. I know that jQuery.textshadow.js is loading. I can find both of the scripts in Developer Tools.

好的!我知道jQuery正在加载。我知道jQuery.textshadow。js是加载。我可以在开发人员工具中找到这两个脚本。

The weird part: this code is working in the content area but not in the banner. Even with a dedicated fixIE.css. AND it works when I put the css inline. (That, of course, messes up FireFox.)

奇怪的部分:这段代码在内容区域中工作,但不在横幅中。即使有专门的fixIE.css。当我将css内联时,它就会工作。(当然,这也会给FireFox带来麻烦。)

I have even put in a conditional IE span around the text field in the banner with no luck.

我甚至在banner中设置了一个条件的IE span。

I found no difference and had the same errors in both jquery-1.4.2.min.js and jquery-1.2.6.min.js. jquery.textshadow.js was downloaded from the jQuery site while trying to find a solution to this problem.

我发现在jquery1.4.2 .min中没有差异,并且有相同的错误。js和jquery-1.2.6.min.js。jquery.textshadow。js是从jQuery站点下载的,同时试图找到这个问题的解决方案。

This is not posted to the Website

这不是发布到网站上的

#1


42  

Write "var" before variables, when you define them. IE8 dies when there is no "var".

在定义变量之前写“var”。IE8在没有“var”时就会死。

#2


39  

Correction:

更正:

Check your script include tag, is it using

检查你的脚本是否包含标签,是否使用

type="application/javascript" src="/path/to/jquery" 

change to

改变

type="text/javascript" src="/path/to/jquery" 

#3


38  

I was having a similar issue. 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

我也有类似的问题。在IE6、Firefox和IE8中工作的东西在IE7兼容模式下运行;但在“正常”的IE8中却不是这样。我的解决方案是把这段代码放到header中

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /> 

As to why jquery isn't working in IE8 I'm unclear.

至于jquery为什么不在IE8中工作,我不清楚。

#4


12  

The solution is to upgrade to the latest version of jQuery. I had the exact same problem and upgraded to 1.4.2 and it all works fine again in IE8.

解决方案是升级到最新版本的jQuery。我也遇到了同样的问题,并将其升级为1.4.2,这在IE8中再次运行良好。

Seems to be totally backwards-compatible with all the jQuery 1.3.2 stuff I did as well so no complaints here!

似乎完全向后兼容所有jQuery 1.3.2,所以这里没有抱怨!

#5


10  

I had this problem and tried the solutions mentioned here with no success.

我遇到了这个问题,尝试了这里提到的解决方法,但没有成功。

Eventually, I realised that I was linking to the Google CDN version of the script using an http URL while the page embedding the script was an https page.

最后,我意识到我正在使用http URL链接到该脚本的谷歌CDN版本,而嵌入该脚本的页面是https页面。

This caused IE to not load jquery (it prompts the user whether they want to load only secure content). Changing the Google CDN URL to use the https scheme fixed the problem for me.

这导致IE不加载jquery(提示用户是否只加载安全内容)。更改谷歌CDN URL以使用https方案解决了我的问题。

#6


8  

Some people stumbling on this post might get this issue with jquery and IE8 because they're using >= jQuery v2. Use this code:

有些人在这篇文章中偶然发现了jquery和IE8的问题,因为他们使用的是>= jquery v2。使用这段代码:

<!--[if lt IE 9]>    <script src="jquery-1.9.0.js"></script><![endif]--><!--[if gte IE 9]><!-->    <script src="jquery-2.0.0.js"></script><!--<![endif]-->

#7


6  

If you are using HTTPS on your site, you will need to load the jQuery library from Googles https server instead. Try this:https://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js(or the latest https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js)

如果在站点上使用HTTPS,则需要从google HTTPS服务器加载jQuery库。试试这个:https://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js(或者最新的https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js)

#8


6  

jQuery is not being loaded, this is not likely specific to IE8. Check the path on your jQuery include. statement. Or better yet, use the following to the CDN:

jQuery没有被加载,这不是IE8特有的。检查jQuery包含的路径。声明。或者更好的是,对CDN使用以下内容:

<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"></script>

#9


5  

I was fixing a template created by somebody else who forgot to include the doctype.

我正在修复一个由其他人创建的模板,这个模板忘记包含doctype。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

If you don't declare the doctype IE8 does strange things in Quirks mode.

如果你不声明doctype IE8,它会以奇怪的方式做一些奇怪的事情。

#10


4  

The error Object expected is raised because Jquery is not loaded. This happens because of browser security (usually IE) which does not allow you executing external javascript source code. You can correct this problem by:

由于未加载Jquery,因此将引发预期的错误对象。这是因为浏览器安全性(通常是IE)不允许执行外部javascript源代码。你可以通过:

  • 1: Changing browser security level to allow executing external javascript code. You can find how to do this here
  • 1:更改浏览器安全级别,允许执行外部javascript代码。你可以在这里找到方法。

OR

  • 2: Copy-paste the jquery source code into your web page so that it won't be considered as an external script.
  • 2:将jquery源代码复制到web页面中,这样就不会将其视为外部脚本。

I prefer the first solution.

我喜欢第一种解决办法。

#11


4  

The onload event does not always work on IE7/8 in <head> ... </head>

onload事件并不总是在中对IE7/8起作用…< / >头

You can force it by adding an onload script at the end of your page before the tag as below.

您可以通过在标签前面的页面末尾添加onload脚本来强制执行,如下所示。

  <script>    window.onload();  </script></body>

#12


2  

Maybe you insert two scripts,it should be work.

也许你插入了两个脚本,应该没问题。

<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE8.js"></script>  <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js">/script> 

#13


2  

This fixed my issue in IE8:

这修正了我在IE8中的问题:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>

Running on localhost, I had to change the https:// to http://

在本地主机上运行时,我必须将https://更改为http://

If I try to browse to the secure link, I get the Internet Explorer cannot display the webpagefriendly warning.

如果我尝试浏览安全链接,我得到Internet Explorer不能显示网页友好的警告。

Always try to load your text scripts in a browswer first if there are issues!

如果有问题,一定要先在浏览器中加载文本脚本!

#14


2  

I had the same problems.

我也有同样的问题。

I solved it verifying that IE8 was not configured correctly to reach the SRC URL.

我解决了它验证IE8没有正确配置以到达SRC URL。

I changed this, it works right.

我改变了这个,它是正确的。

#15


1  

Maybe you have inPrivate Filtering turned on?

也许你打开了inPrivate过滤?

#16


1  

I had the same issue. The solution was to add the link to the JQuery file as a trusted site in IE.

我有同样的问题。解决方案是将JQuery文件的链接添加到IE中的受信任站点。

#17


1  

I think that you have same problem as I do:

我认为你和我有同样的问题:

Message: Permission deniedLine: 13Char: 27021Code: 0URI: http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.3.2.min.js

Because of cross domain reference. Try to host jquery.js on same domain.

因为交叉域引用。主机jquery。js在相同的域。

#18


0  

In short, it's because of the IE8 parsing engine.

简而言之,这是因为IE8解析引擎。

Guess why Microsoft has trouble working with the new HTML5 tags (like "section") too? It's because MS decided that they will not use regular XML parsing, like the rest of the world. Yes, that's right - they did a ton of propaganda on XML but in the end, they fall back on a "stupid" parsing engine looking for "known tags" and messing stuff up when something new comes around.

猜猜为什么微软在处理新的HTML5标签时遇到了麻烦(比如“section”)?这是因为MS决定不使用常规的XML解析,就像世界其他地方一样。是的,没错——他们在XML上做了大量宣传,但最终,他们求助于一个寻找“已知标记”的“愚蠢”解析引擎,并在出现新东西时把东西搞得一团糟。

Same goes for IE8 and the jquery issue with "load", "get" and "post". Again, Microsoft decided to "walk their own path" with version 8. Hoping that they solve(d) this in IE9, the only current option is to fall back on IE7 parsing with <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />.

IE8和jquery关于“load”、“get”和“post”的问题也是如此。再次,微软决定“走自己的路”与版本8。希望在IE9中解决这个问题(d),目前唯一的选择是使用 进行IE7解析。

Oh well... what a surprise that Microsoft made us post stuff on forums again. ;)

哦……微软又让我们在论坛上发东西,真是令人惊讶。,)

#19


0  

The solution in my case was to take any special characters out of the URL you're trying to access. I had a tilde (~) and a percentage symbol in there, and the $.get() call failed silently.

在我的例子中,解决方案是从要访问的URL中取出任何特殊字符。我有一个波浪符号(~)和一个百分比符号,$.get()调用静默失败。

#20


0  

OK! I know that jQuery is loading. I know that jQuery.textshadow.js is loading. I can find both of the scripts in Developer Tools.

好的!我知道jQuery正在加载。我知道jQuery.textshadow。js是加载。我可以在开发人员工具中找到这两个脚本。

The weird part: this code is working in the content area but not in the banner. Even with a dedicated fixIE.css. AND it works when I put the css inline. (That, of course, messes up FireFox.)

奇怪的部分:这段代码在内容区域中工作,但不在横幅中。即使有专门的fixIE.css。当我将css内联时,它就会工作。(当然,这也会给FireFox带来麻烦。)

I have even put in a conditional IE span around the text field in the banner with no luck.

我甚至在banner中设置了一个条件的IE span。

I found no difference and had the same errors in both jquery-1.4.2.min.js and jquery-1.2.6.min.js. jquery.textshadow.js was downloaded from the jQuery site while trying to find a solution to this problem.

我发现在jquery1.4.2 .min中没有差异,并且有相同的错误。js和jquery-1.2.6.min.js。jquery.textshadow。js是从jQuery站点下载的,同时试图找到这个问题的解决方案。

This is not posted to the Website

这不是发布到网站上的