<!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>

 

相关文章:

  • 2021-09-03
  • 2022-02-07
  • 2021-11-25
  • 2021-11-03
  • 2021-07-02
  • 2021-08-03
  • 2022-02-11
  • 2021-10-20
猜你喜欢
  • 2022-12-23
  • 2021-11-27
  • 2022-12-23
  • 2021-12-05
  • 2021-06-14
  • 2021-11-27
  • 2021-11-27
相关资源
相似解决方案