Each height and width in JavaScript is differentiated

Source: Internet
Author: User

JS Gets the height of the document: Math.max (document.body.scrollheight,document.documenelement.scrollheight);

JS Gets the height of the viewable area of the browser: Math.max (document.body.clientHeight, document.documentElement.clientHeight)//window.innerheight;

JS Get scroll bar height: document.documentElement.scrollTop | | Document.body.scrollTop;

jquery Gets the height of the document: $ (document). Height ();

jquery Gets the height of the viewable area of the browser: $ (window). Height ();

Scroll bar Scroll Height: $ (window). scrolltop ();

$ (document) when the page height is less than the browser window. Height () returns a $ (window). Height ().

Width and height!

Here is a more example of a rolling load:

1 varPage=1; 2         varFinished=0; 3         varsover=0;//is full screen4         varSubjectids =${subjectids}; 5         varLen =subjectids.length;6         //If the screen does not go to full screen auto-load Next page fills up7         varSetdefult=setinterval (function (){  8             if(sover==1){  9 clearinterval (Setdefult); Ten}Else if($ (". Dvd-box"). Height () < Window.innerheight | | len<4) {  OneLoadmore ($ (window),true);  A}Else   - clearinterval (Setdefult);  -},500);  the            -         //load More -         functionLoadmore (obj,flag) { -             //flag, under full screen condition.  +             if(Finished==0 && sover==0){   -                 varScrollTop =$ (obj). scrolltop ();  +                 varScrollHeight = $ (document). Height ();//Document Height A                 varWindowHeight = Window.innerheight;//Visible Area Height at  -                 if($ (". Loadmore"). length==0) {   -                     vartxt= ' <div class= "Loadmore" ><span class= "Loading" ></span> loading in: </div> ' -$ (". Dvd-box"). append (TXT);  -                 }   -                 if(Flag | | scrollheight-scrolltop-windowheight <=500 ) {   in                     //here is the event triggered by the scroll bar to the bottom, where the data to be loaded is written, or the action that pulls the scroll bar -                     //prevent execution after not loading toFinished=1;  + $.ajax ({ -Type: ' GET ',   theURL: "alb/index/" +Subjectids[page], *Successfunction(data) { $                                 if(data== ""){  Panax NotoginsengSover = 1;  -                                     if(page = = 1) {   the$ (". Loadover"). Remove ();  +                                     }   A}Else{ theSetTimeout (function(){   +                                        /*$ (". Loadmore"). Remove ();*/   -$ ('. Dvd-box. Loadmore '). before (data);  $ lazyload (); $ imgerror (); -Page+=1;  -Finished=0;  the                                         //last page -                                         if(page==Len) {  WuyiSover=1;  the$ (". Loadmore"). Remove ();  -                                         }   Wu},100);  -                                 }   About                             },   $Errorfunction(XHR, type) { -Console.log (' Ajax error! ');  -                             }   -                         });  A                         +                 }   the             }   -         }   $         //page scrolling Execution Events the$ (window). Scroll (function (){   theLoadmore ($ ( This));  the});

Each height and width in JavaScript is differentiated

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.