HTML Get window height width __html

Source: Internet
Author: User

Sometimes we need to get the size of the window to fit the different display on different screens, the event that triggers when the screen is changed

$ (window). Resize (function () {
The code you want to execute
});

document.write ($ (window). Height ()); The window's visible area is document.write ($ (document)). Height ()); The height of the window document in the browser nowadays
document.write ($ (document.body). Height ());//browser Current window document body level
document.write ($ (document.body). Outerheight (True))//Browser The total height of the body of the window document currently includes border padding margin
document.write ($ (window). width ()); Window viewable area width in browser
document.write ($ (document). width ());//browser Current window document for image widths
document.write ($ (document.body). width ());//browser Current window document body height
document.write ($ (document.body). Outerwidth (True))//Browser The total width of the body of the window document currently includes border padding margin
document.write ($ (document). ScrollTop ()); Gets the vertical height of the scroll bar to the top

document.write ($ (document). ScrollLeft ()); Gets the vertical width of the scroll bar to the left


$ (document) when the document is in a window with a height of less than the browser window. Height () returns $ (window). Height ().
$ ("body"). Height ()   If the body has no border, margin, $ ("body"). Height () ==$ (document). Height (), However, it is not recommended that you use this approach to get the document content height

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.