document.body 在带有 jquery 的 IE 8 窗口中为 null

发布于 2024-10-04 04:26:11 字数 195 浏览 0 评论 0原文

我有一个奇怪的错误,只发生在 Window 7 和 IE 8 中。

我在 html 中使用 jQuery。我双击并在 IE 中启动 html。第一次在jquery库中会显示错误document.body is null。但当我重新加载页面后,错误就会消失。 html只加载jquery js文件,没有其他js或css。

在其他浏览器中没有发生。

I have a strange error only happen in Window 7 and IE 8.

I use jQuery in a html. I double click and launch the html in IE. It will show error document.body is null inside the jquery library in the first time. But the error will disappear after i reload the page. The html just loading the jquery js file only and no other js or css.

Didn't happen in other browser.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一世旳自豪 2024-10-11 04:26:11

看起来外部脚本是在定义文档主体之前加载的。
因此,您只需将脚本中包含 $(document).ready 的部分放在 的末尾即可。

It looks like the external script is loaded before the document body can be defined.
So you can just place the portion of your script that has $(document).ready at the end of <body></body>.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文