Obtain the height and width of the window, visible window, and scroll bar.

Source: Internet
Author: User

[Javascript]

Javascript:

Visible area width of the webpage: document. body. clientWidth
Visible area height: document. body. clientHeight
Visible area width of the webpage: document. body. offsetWidth (including the width of the edge)
Visible area height of the webpage: document. body. offsetHeight (including the height of the edge)
Webpage text width: document. body. scrollWidth
Webpage text height: document. body. scrollHeight
The height of the page to be rolled: document. body. scrollTop
Left: document. body. scrollLeft
Page body: window. screenTop
Page body part left: window. screenLeft
Screen Resolution height: window. screen. height
Screen Resolution width: window. screen. width
Available screen workspace Height: window. screen. availHeight
Available workspace width: window. screen. availWidth

 
Javascript:
 
Visible area width of the webpage: document. body. clientWidth
Visible area height: document. body. clientHeight
Visible area width of the webpage: document. body. offsetWidth (including the width of the edge)
Visible area height of the webpage: document. body. offsetHeight (including the height of the edge)
Webpage text width: document. body. scrollWidth
Webpage text height: document. body. scrollHeight
The height of the page to be rolled: document. body. scrollTop
Left: document. body. scrollLeft
Page body: window. screenTop
Page body part left: window. screenLeft
Screen Resolution height: window. screen. height
Screen Resolution width: window. screen. width
Available screen workspace Height: window. screen. availHeight
Available workspace width: window. screen. availWidth
[Javascript]
JQuery:

$ (Document). ready (function (){
 
 
 
Alert ($ (document). height (); // The height of the current window document in the browser
 
 
Alert ($ (document. body). height (); // The height of the current window body in the browser
 
 
Alert ($ (document. body). outerHeight (true); // the total height of the current window document body in the browser includes border padding margin
 
 
Alert ($ (window). width (); // The width of the visible area of the current window in the browser
 
 
Alert ($ (document). width (); // The image width of the window document in the browser
 
 
Alert ($ (document. body). width (); // The height of the current window body in the browser
 
 
Alert ($ (document. body). outerWidth (true); // The total width of the current window body in the browser includes border padding margin
 
 
Alert ($ (document). scrollTop (); // gets the vertical height from the scroll bar to the top.
 
 
Alert ($ (document). scrollLeft (); // gets the vertical width from the scroll bar to the left.

})

Related Article

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.