Query Gets the height and width of the browser window

Source: Internet
Author: User

We use jquery to develop the process we sometimes based on the location of the browser window, the following explains some ways to get the browser window size.

Browser viewable area size, note that this refers not to the browser window size, nor the page size, we can imagine that we can see the size of the document area

  • The viewable area height in the current browser window: $ (window). Height ()
  • The width of the viewable area in the current browser window: $ (window). Width ()

Browser size of the entire document

  • The height of the current document: $ (document). Height ()
  • The width of the current document: $ (documents). Width ()

browser window document body

  • The height of the body of the window document: $ (document.body). Height ()
  • Window Document Body width: $ (document.body). Width ()

Window document body Total height, total width (including padding, border, margin)

  • The total height of the body of the window document (including padding, border, margin): $ (document.body). Outerheight (True)
  • The total width of the body of the window document (including padding, border, margin): $ (document.body). Outerwidth (True)

Scroll bar correlation value gets

  • The distance from the top of the scroll bar: $ (document). ScrollTop ()
  • The distance from the scroll bar to the left: $ (document). ScrollLeft ()

Query Gets the height and width of the browser window

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.