<script?type="text/javascript">
????var?wid=document.documentElement.scrollWidth||document.body.scrollWidth;
????var?hei=document.documentElement.scrollHeight||document.body.scrollHeight;
????alert('width='+wid+'?height='+hei);
</script>如上圖,此時文檔內容為空, 獲取到的scrollHeight為8px但是當把body的margin設置為0px 時body{margin:0px;},獲取到的crollHeight就和clientHeight相同,這是為什么謝謝大神們解答
在chrome中用scrollHeight獲取網頁高度時的疑問
那一年美然
2016-04-20 15:53:41