Home >Web Front-end >JS Tutorial >js method to get the height and width of the page_javascript skills

js method to get the height and width of the page_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:58:25848browse

When I was making a pop-up dialog today, I encountered 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. Later I found an efficient method. , share it with everyone immediately:

Add breakpoint debugging [debugger] where you need to get the height and width, then enter document.body in the monitoring page, check all body attributes to see which result you need Yes, if it is not suitable, you can also enter window, and then see if there are suitable attributes under the window. My problem was solved in this way today. The attributes are window.innerWidth and window.innerHeight.

I hope everyone can avoid detours when encountering such problems.

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