开发者社区> 问答> 正文

在chrome中用scrollHeight获取整个网页高度时,为什么body有和没有margin会得到不一样的返回值

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">

</style>
</head>
<body>
<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>
</body>
</html>

screenshot

展开
收起
杨冬芳 2016-06-12 18:56:15 2163 0
0 条回答
写回答
取消 提交回答
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载