<!DOCTYPE HTML><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><style type="text/css">body{border:3px red solid;? ? padding:0;? ? margin:0;}</style></head><body><p>yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy</p><p>yyy</p><p>yyy</p><p>yyy</p><p>yyy</p><p>yyy</p><p>yyy</p><p>yyy</p><p>yyy</p><p>yyy</p><p>yyy</p><p>yyy</p><p>yyy</p><p>yyy</p><p>yyy</p><p>yyy</p><p>yyy</p><p>yyy</p><p>yyy</p><p>yyy</p><p>yyy</p><p>yyy</p><p>yyy</p><p>yyy</p><p>yyy</p><p>yyy</p><p>yyy</p><p>yyy</p><p>yyy</p><p>yyy</p><p>yyy</p><p>yyy</p><p>yyy</p><p>yyy</p><p>yyy</p><p>yyy</p><script type="text/javascript">var h=document.documentElement.offsetHeight;var w=document.documentElement.offsetWidth;document.write(h+"<br>");document.write(w+"<br>");document.write("<br>");var h2=document.documentElement.scrollHeight;var w2=document.documentElement.scrollWidth;document.write(h2+"<br>");document.write(w2+"<br>");document.write("<br>");var h1=window.innerHeight;var W1=window.innerWidth;var h1_1=document.documentElement.clientHeight;var W1_1=document.documentElement.clientWidth;var h1_2=document.body.clientHeight;var W1_2=document.body.clientWidth;document.write(h1+" "+h1_1+" "+h1_2+"<br>");document.write(W1+" "+W1_1+" "+W1_2+"<br>");document.write("<br>");</script></body></html>這是得到的結(jié)果1246130813002147605?588?13481325?1308?1302為什么我測(cè)試出來的document.documentElement.offsetWidth;的寬度減去了滾動(dòng)條寬度17px,不是說包含滾動(dòng)條寬度嗎?如果刪去了上面內(nèi)容是三個(gè)Y的所有p元素,這時(shí)document.documentElement.scrollHeight小于document.documentElement.clientHeight,但卻沒有返回一個(gè)值等于它document.documentElement.clientHeight。
為什么我測(cè)試出來的document.documentElement.offsetWidth;不包含滾動(dòng)條寬度
慕姐8259394
2017-08-06 20:08:56