Javascript code for getting pages and element heights and widths _ javascript skills

Source: Internet
Author: User
The following small series will bring you a javascript code for getting pages and element height and width. I think this is quite good. Now I will share it with you and give you a reference on the 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 and scroll bar );
Visible area height of the webpage: document. body. offsetHeight (including the width of the edge );
Full text width of the webpage: document. body. scrollWidth;
Webpage text height: document. body. scrollHeight;
The height of the page to be rolled (ff): document. body. scrollTop;
The height of the page to be rolled (ie): document.doc umentElement. scrollTop;
Left of the webpage to be rolled: document. body. scrollLeft;
Page body: window. screenTop;
Page body part left: window. screenLeft;
The width of an element: obj. offsetWidth;
Height of an element: obj. offsetHeight;
The distance from the upper boundary of an element to the top of the body: obj. offsetTop; (if the element containing the element does not contain the scroll bar)
The leftmost distance from the left boundary of an element to the body: obj. offsetLeft; (if the element containing the element does not contain the scroll bar)
Returns the offset from the upper boundary of the current element to the upper boundary of the element containing the element: obj. offsetTop (when the element contains the element containing the scroll bar)
Returns the offset from the left boundary of the current element to its left boundary containing the element: obj. offsetLeft (when the element contains the scroll bar)

ScrollTop, scrollLeft

Sets or returns the number of shards that have been rolled to the left or upper boundary of the element. These pixels are useful only when the element has a scroll bar, for example, when the CSS overflow attribute of the element is set to auto. These attributes are only available inOrMark the definition (this is related to the browser) and work together to determine the location of the rolling document. Note that these attributes do not specifyThe number of scrolling labels. This is a non-standard but well-supported attribute <br/> </p> <p> the above js Code for retrieving pages and element height and width is shared by xiaobian. all content, I hope to give you a reference, and I hope you can also support your own home.

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.