Home > Web Front-end > JS Tutorial > body text

JS code interpretation for obtaining page window size_javascript skills

WBOY
Release: 2016-05-16 17:58:45
Original
1250 people have browsed it

The code in this section mainly uses some properties of the Document object regarding the window. The main functions and usage of these properties are as follows.
To get the size of the window, different properties and methods need to be used for different browsers: to detect the real size of the window, you need to use the properties of the Window under Netscape; under IE you need to go deep inside the Document to perform the body Detection; In the DOM environment, if you want to get the size of the window, you need to pay attention to the size of the root element , not the element.
The innerWidth property of the Window object contains the inner width of the current window. The innerHeight property of the Window object contains the inner height of the current window.
The body attribute of the Document object corresponds to the tag of the HTML document. The documentElement property of the Document object represents the root node of the HTML document.
document.body.clientHeight represents the current height of the window where the HTML document is located. document.body.clientWidth represents the current width of the window where the HTML document is located.

Copy code The code is as follows:

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> www.w3.org/1999/xhtml">

Please resize the browser window



Please resize the browser window< /h2>



The actual height of the browser window:

The actual width of the browser window: < input type="text" name="availWidth" size="4">


Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template

About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!