为什么 google chrome 的控制台在页面刷新之间具有不同的文档对象表示形式?
为了自己确定 Chrome 浏览器中“文档”变量的可靠性,我构建了一个简单的 HTML 文件,如下所示:
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>index</title>
<script type="text/javascript" charset="utf-8">
console.log( document )
</script>
</head>
<body></body>
</html>
我假设这会导致“文档”变量的值在每个页面加载并且每次都会完全相同。
然而事实并非如此。在第一次刷新时,控制台输出一个“Document”对象,在下一次刷新时,它输出一个“HTMLDocument”对象,依此类推,在两者之间来回切换。
有人能解释一下这是怎么回事吗?
In a attempt to determine for myself the reliability of the "document" variable in the Chrome Browser I built a simple HTML file like such:
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>index</title>
<script type="text/javascript" charset="utf-8">
console.log( document )
</script>
</head>
<body></body>
</html>
I assumed that this would cause the value of the "document" variable to be echoed to the console on every page load and would be the exact same every time.
Yet this is not what happens. On the first refresh the console outputs a "Document" object and on the next refresh it outputs a "HTMLDocument" object and so on, toggling back and forth between the two.
Can anybody explain what is going on here?
Screencast: http://youtu.be/q0r_Q0wW8f8
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论