首页 > Web开发 > 详细

js获得浏览器的尺寸

时间:2016-06-14 01:02:51      阅读:229      评论:0      收藏:0      [点我收藏+]
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>获得网页可见区域宽度</title>
    <script type="text/javascript">
        function show() {
            var s = "";
            s += "网页可见区域宽度:" + document.body.clientWidth;
            s += "\n网页可见区域高度:" + document.body.clientHeight;
            s += "\n网页可见区域宽度(包括边线):" + document.body.offsetWidth;
            s += "\n网页可见区域高度(包括边线):" + document.body.offsetHeight;
            s += "\n网页正文宽度:" + document.body.scrollWidth;
            s += "\n网页正文高度:" + document.body.scrollHeight;
            s += "\n屏幕可用工作区域宽度:" + window.screen.availWidth;
            s += "\n屏幕可用工作区域高度:" + window.screen.availHeight;
            s += "\n屏幕分辨率宽度:" + window.screen.width;
            s += "\n屏幕分辨率高度:" + window.screen.height;
            alert(s);
        }
    </script>
</head>
<body style="margin:0;border:0">
<div style="width:2000px;height:90px;margin:0">
    <a onclick="show()" href="#">点击</a>
    <button onclick="show()">点击</button>
</div>
</body>
</html>

 

js获得浏览器的尺寸

原文:http://www.cnblogs.com/hllive/p/5582445.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!