window objectLOGIN

window object

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.


Next Section
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>window对象</title> <script type="text/javascript"> function myFunction() { alert("欢迎来到phpd中文网") window.open('http://www.php.cn','_blank','width=600 height=400') } </script> </head> <body> <form> <input type="button" value="点击我,打开新窗口" onclick="myFunction()" /> </form> </body>
submitReset Code
ChapterCourseware