【问题标题】:HTML/DOM: What is standards equivalent of document.body.scrollHeight?HTML/DOM:document.body.scrollHeight 的标准等价物是什么?
【发布时间】:2011-04-16 20:57:21
【问题描述】:

近十年来我一直在使用:

document.body.scrollHeight 

返回浏览器窗口的“理想”高度。当我使用 quirks-mode doctype 强制 Internet Explorer 进入 quirks 模式 时,这工作正常:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

现在我想选择标准模式the meaning of scrollHeight has changed 除外:

  • 怪癖模式document.body.scrollHeight = 文档高度
  • 标准模式document.body.scrollHeight = &lt;body&gt; 元素的高度

document.body.scrollHeight 等效的标准模式是什么?

另见

【问题讨论】:

    标签: internet-explorer dom html quirks-mode


    【解决方案1】:

    document.documentElement.scrollHeight我相信。

    对于现代浏览器,视口为 window.innerHeight

    如果以上不是你想要的,这里有一堆列表:

    • document.documentElement.[scrollHeight,clientHeight,offsetHeight]
    • document.body.[scrollHeight,clientHeight,offsetHeight]
    • window.[inner,outer][Height,Width](仅限现代浏览器)

    【讨论】:

    • 做到了,当 IE 托管在 Win32 应用程序中时,将代码 document.body.getAttribute("scrollHeight", 0) 更改为 document.documentElement.getAttribute("scrollHeight", 0)
    猜你喜欢
    • 2014-11-22
    • 2022-06-12
    • 2012-04-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-09
    • 2012-06-29
    • 2014-05-08
    相关资源
    最近更新 更多