问答详情
源自:9-18 浏览器窗口可视区域大小

就这样子啦

<!DOCTYPE HTML>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

</head>

<body>

<script type="text/javascript">

var w=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth;

var h=window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight;

document.write(w+"<br/>"+h);

</script>

</body>

</html>


提问者:玄众妙 2019-05-29 10:32

个回答

  • 晚风铃铃
    2019-07-09 15:04:47

    var w= document.documentElement.clientWidth
          || document.body.clientWidth;
    var h= document.documentElement.clientHeight
          || document.body.clientHeight;

    注意格式