Example code: use javascript to get the webpage document height

Source: Internet
Author: User

DocumentHow can I use JAVASCRIPT to obtain the height and width of the current window? Some time ago, In the csdn programmer development website's communication forum, I saw a friend asking me, and whether the friend asks about the usefulness of this Code, let's take a look at the best answer. This is an example code, all of them are marked, which is of great help to cainiao webmaster.

Reference content is as follows:
<Script type = "text/javascript">
Var s = "";
S + = "\ r \ n visible area width of the webpage:" + document.doc umentElement. clientWidth;
S + = "\ r \ n visible area of the webpage:" + document.doc umentElement. clientHeight;
S + = "\ r \ n visible area width of the webpage:" + document.doc umentElement. offsetWidth + "(including the width of the edge )";
S + = "\ r \ n visible area height of the webpage:" + document.doc umentElement. offsetHeight + "(including the width of the edge )";
S + = "\ r \ n webpage body full text width:" + document.doc umentElement. scrollWidth;
S + = "\ r \ n webpage text Height:" + document.doc umentElement. scrollHeight;
S + = "\ r \ n webpage volume Height:" + document.doc umentElement. scrollTop;
S + = "\ r \ n left when the webpage is rolled:" + document.doc umentElement. scrollLeft;
S + = "\ r \ n webpage body part:" + window. screenTop;
S + = "\ r \ n left part of the webpage body:" + window. screenLeft;
S + = "\ r \ n screen resolution height:" + window. screen. height;
S + = "\ r \ n screen resolution width:" + window. screen. width;
S + = "\ r \ n available workspace Height:" + window. screen. availHeight;
S + = "\ r \ n available workspace width of the screen:" + window. screen. availWidth;
Alert (s );
</Script>

Through the above code, we can clearly see the comments of each statement. We suggest you run the above Code to see the effect!

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.