为了账号安全,请及时绑定邮箱和手机立即绑定

不是很明白documentElement.clientWidth和body.clientWidth的区别,我在360浏览器上实现的,分别为601*370,600*370,36*354,求解

<!DOCTYPE HTML>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

</head>

<body>

<script type="text/javascript">

document.write("当前窗口大小为"+window.innerHeight+"*"+window.innerWidth+"<br>");


document.write("当前窗口大小为"+document.documentElement.clientHeight+"*"+document.documentElement.clientWidth +"<br>");

document.write("当前窗口大小为"+document.body.clientHeight+"*"+document.body.clientWidth +"<br>");


</script>

</body>

</html>


正在回答

1 回答

body是DOM对象里的body子节点,即 <body> 标签;

documentElement 是整个节点树的根节点root,即<html> 标签;

clientWidth 是元素的内容和padding值,没有算边框

document.body.clientWidth  和 document.documentElement.clientWidth获取的值可能会不同。

3 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

不是很明白documentElement.clientWidth和body.clientWidth的区别,我在360浏览器上实现的,分别为601*370,600*370,36*354,求解

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信