<!DOCTYPE html> <html> <body> <p id="demo"></p> <script> var w=window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; var h=window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight; x=document.getElementById("demo"); x.innerHTML="浏览器的内部窗口宽度:" + w + ",高度:" + h + "。" </script> </body> </html>
使用浏览器打开,可查看浏览器视口大小