Dom Operation three

Source: Internet
Author: User

1. Returns the offset of the scrollbar as an object's X and Y properties

functionGetscrolloffsets (w) {//Use the specified window if the current window is used without parametersw= W | |window; //in addition to IE 8 and earlier versions, other browsers are available    if(W.pagexoffset! =NULL)          return{X:w.pagexoffset,y:w.pageyoffset}; //ie in the standard mode    varD=w.document; if(document.compatmode== "Css1compat"){          return{x:d.documentelement.scrollleft,y:d.documentelement.scrolltop}; }    //The browser in the weird mode    return{x:d.body.scrollleft,y:d.body.scrolltop};}

2. The viewport dimensions of the query window

functionGetviewportsize (w) {//Use the specified window if the current window is used without parametersw= W | |window; //in addition to IE 8 and earlier versions, other browsers are available    if(w.innerwidth!=NULL)          return{w:w.innerwidth,h:w.innerheight}; //ie in the standard mode    varD=w.document; if(document.compatmode== "Css1compat"){          return{w:d.documentelement.clientwidth,h:d.documentelement.clinetheight}; }    //The browser in the weird mode    return{w:d.body.clientwidth,h:d.body.clientwidth};}

Dom Operation three

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.