<!DOCTYPE html> <html> <body> <h1>Document 对象</h1> <h2>defaultView 属性</h2> <p>defaultView 属性返回当前窗口对象。</p> <p>窗口的宽度和高度为:</p> <p id="demo"></p> <script> const view = document.defaultView; let width = view.innerWidth; let height = view.innerHeight; document.getElementById("demo").innerHTML = width + "x" + height; </script> </body> </html>