JS get the height and width of the page _javascript tips

Source: Internet
Author: User
Today in doing a pop-up dialog, the use of the parent page to take the width and height of the method.

Tried a few ways, such as Document.body.clientwidth,window.screen.width,document.body.scrollwidth and other methods, the discovery is not the result I want, and later found an efficient way to share it immediately:

Add breakpoints to debug "debugger" where height and width are required. Then in the Monitoring page to enter Document.body, see the properties of all the body to see which result is what you need, if not suitable can also enter window, and then see if there is a suitable property window, today my problem solving is solved by this way, the attribute is Window.inne Rwidth and Window.innerheight.

Hope that you encounter such problems can be less detours.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.