JS element is wide, the viewable area is wide, the scrolling area is wide and the height of scrolling is high

Source: Internet
Author: User

1. High document height, high document area of the screen

Document.body.clientHeight

2. Effective high, high screen visibility

Document.documentElement.clientHeight

3. Total height of the screen

Document.documentElement.scrollHeight

4. The height of the scroll

Document.documentElement.scrollTop

JS Code

<Script>
Gain effective width and height, wide screen visibility
VarWinX=Document.DocumentElement.ClientWidth;
VarWiny=Document.DocumentElement.ClientHeight;
AlertWinX);
AlertWiny);

Gets the width and height of the body text area
VarWinxx=Document.Body.ClientWidth;
VarWinyy=Document.Body.ClientHeight;
AlertWINXX);
AlertWinyy);

Get the total width and height
VarWinxxx=Document.DocumentElement.ScrollWidth;
VarWinyyy=Document.DocumentElement.ScrollHeight;
AlertWINXXX);
AlertWINYYY);

Height of scrolling This method has compatibility issues
Window.Onscroll= function () {
Determine if the browser you are using is chrome
IfNavigator.UserAgent.IndexOf ("Chrome")>-1) {
For Google Chrome
VarWiny=Document.Body.ScrollTop }else{
//for IE , Firefox
var winy Span style= "color: #fbde2d;" >= document. documentelement. scrolltop
document. Title = winy };
</SCRIPT>
</HTML>

JS element is wide, the viewable area is wide, the scrolling area is wide and the height is scrolled

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.