JavaScript can obtain many objects provided by the browser and perform operations.
window
The window object not only serves as the global scope, but also represents the browser window.
The window object has innerWidth and innerHeight properties, which can get the internal width and height of the browser window. The internal width and height refers to the net width and height used to display the web page after removing placeholder elements such as menu bars, toolbars, and borders.
Compatibility: IE<=8 is not supported.
<html> <head> <script> 'use strict'; alert('window inner size: ' + window.innerWidth + ' x ' + window.innerHeight); </script> </head> <body> </body> </html>
Correspondingly, there is also an outerWidth and outerHeight attribute, which can obtain the entire width and height of the browser window.