document.body 在带有 jquery 的 IE 8 窗口中为 null
我有一个奇怪的错误,只发生在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来外部脚本是在定义文档主体之前加载的。
因此,您只需将脚本中包含
$(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>
.