HTML / DOM:什么是document.body.scrollHeight的标准? [英] HTML/DOM: What is standards equivalent of document.body.scrollHeight?

查看:416
本文介绍了HTML / DOM:什么是document.body.scrollHeight的标准?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

近十年来,我一直在使用:

For nearly a decade i've been using:

document.body.scrollHeight 

返回浏览器窗口的理想高度。当我使用怪异模式doctype 强制将IE浏览器设置为 怪异模式 时,这可以正常工作:

to return the "ideal" height of the browser window. This worked fine when i was forcing Internet Explorer into quirks mode, by using a quirks-mode doctype:

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

现在我想选择加入 标准模式 <$ c的含义除外$ c> scrollHeight 已更改

Now i want to opt into standards mode, except the meaning of scrollHeight has changed:


  • 怪癖模式 document.body.scrollHeight =文档的高度

  • 标准模式 document.body.scrollHeight = < body> 元素
  • 的高度
  • Quirks Mode: document.body.scrollHeight = the height of the document
  • Standards Mode: document.body.scrollHeight = the height of the <body> element

什么标准模式相当于 document.body.scrollHeight

  • quirksmode.org: W3C DOM Compatibility - CSS Object Model View - ElementView properties
  • Using !DOCTYPE invalidates client height

推荐答案

document.documentElement.scrollHeight 我相信。

对于viewport,它是 window.innerHeight 为现代浏览器。

For viewport it's window.innerHeight for modern browsers.

如果上述不是你想要的,这里列出一堆他们:

If the above aren't what you want, here's a list of a bunch of them:


  • document.documentElement。[scrollHeight,clientHeight,offsetHeight]

  • document.body。[scrollHeight,clientHeight,offsetHeight] / li>
  • 窗口[内,外] [高度,宽度](仅限现代浏览器)

这篇关于HTML / DOM:什么是document.body.scrollHeight的标准?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆