Home >Web Front-end >JS Tutorial >Get the height and width of the page through js

Get the height and width of the page through js

巴扎黑
巴扎黑Original
2017-03-19 17:44:151128browse

[Introduction] When I was making a pop-up dialog today, I came across the method of getting the width and height of the parent page. After trying several methods, such as document body clientWidth, window screen width, document body scrollWidth and other methods, I found that none of them were the results I wanted. Finally

When I was making a pop-up dialog today, I encountered the problem of fetching The width and height methods of the parent page.

After trying several methods, such as document.body.clientWidth, window.screen.width, document.body.scrollWidth, etc.

, I found that none of them are what I want. As a result, I later discovered an efficient method and immediately shared it with everyone:

Add breakpoint debugging [debugger] where the height and width need to be obtained, and then enter document.body in the monitoring page , check all

body attributes to see which result you need. If it is not suitable, you can also enter window, and then see if there are suitable attributes under window. My question today is

The solution is solved in this way, the properties are window.innerWidth and window.innerHeight.

The above is the detailed content of Get the height and width of the page through js. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn