0

I am testing my script in IE9. I noticed that $(document).ready is not always being called. That means 1 out of 8 times the function referred by $(document).ready is not being called.

As soon as I move the $(document).ready call to the end of the document, it works perfectly. The problem arises only if I move the $(document).ready call to the section.

I read through the blog post that confirms this problem in IE6: http://webbugtrack.blogspot.ca/2007/08/bug-153-self-closing-script-tag-issues.html

Considering the reputation of JQuery, I am surprised by the issue. Is this a known issue/bug and workaround for JQuery? Or am I missing anything?

Thank you,

UPDATE:

I just wanted to update with regards to this issue:

The script was working fine on the other browsers (Chrome and FF), only my dev machine's IE was problematic. Once I reset IE (reset and restore on the IS settings’ advanced tab) $(document).ready started to work as expected. So I know the solution, but I like to know the root cause.

While I am disappointed on IE’s shaky behavior, this case is left with an unanswered question: One of IE’s setting changes the way that $(document).ready behaves, and it causes the problem I explained in this post. Does anybody know which setting cased this issue?

4

2 回答 2

0

我已经能够重现这个问题。这个问题是零星的。我正在使用数据表和 jquery 版本 jquery-1.10.2。我已经确认没有触发 ready 事件。为了重现,IE 页面通过链接打开目标窗口名称。
例如转到第 2 页

单击该链接会打开一个新选项卡,其中包含一个带有数据表的页面。我将把这个新页面称为page#2,将它称为page#1。我没有关闭第 2 页。我返回第 1 页并再次单击该链接。如果我在选项卡(page#1 和 page#2)之间切换,我可以看到每 4 次尝试中大约有 1 次 page#2 没有与数据表(仅表)一起呈现。此外,浏览器窗口的左下角显示黄色感叹号。

于 2013-08-28T17:57:17.430 回答
0

听起来您可能正在使用 jQuery 1.8.0。

jQuery 1.8.0 引入了一个错误,导致 ready 方法在 IE9 中过早触发。

该错误已在 1.8.1 中修复,并且仍然在 1.8.2 中修复。如果您当前使用的是 1.8.0,升级到这两个版本中的任何一个都应该可以解决该问题。

1.8.1 的发行说明中提到了该错误http://blog.jquery.com/2012/08/30/jquery-1-8-1-released/

这是票:http ://bugs.jquery.com/ticket/12282

于 2012-09-26T19:30:29.133 回答