JS Get window Size

Source: Internet
Author: User
Keywords Web page production Ajax javascript
Tags ajax code document full text function get high javascript

There are two of the following about JS to get the window size instance code, get the window size method is to use the JS Document.body.clentwidth method to example. There are many methods, which are described in detail below.

<script>
Function GetInfo ()
{
    var s = "";
    s + + page visible area wide: + document.body.clientwidth;
    S + + "Web page visible Area High:" + document.body.clientheight;
    S + + page visible area wide: "+ Document.body.offsetwidth +" (including Edge and scroll bar width); The
    s + + page visible area is High: "+ Document.body.offsetheight +" (including edge width);
    S + + "Web page full text width:" + document.body.scrollwidth;
    S + = "The full text of the page is high:" + document.body.scrollheight;
    S + + pages are rolled high (FF): "+ document.body.scrolltop;"
    S + + pages are rolled high (ie): "+ document.documentelement.scrolltop; The
    S + + page is rolled away to the left: "+ document.body.scrollleft;
    S + + page body part: "+ window.screentop;
    S + + page body part left: "+ window.screenleft;
    S + = "high screen resolution:" + window.screen.height;
    S + + screen resolution width: + window.screen.width;
&NBSP;&NBsp;  s + + screen available Workspace height: + window.screen.availheight;
    S + + screen available workspace width: + window.screen.availwidth;
    s + + "your screen setting is" + window.screen.colordepth + "bit color";
    s + + "your screen settings" + window.screen.devicexdpi + "pixel/inch";
   //alert (s);
}
GetInfo ();
</script>

Commonly used

    Web page visible area wide:document.body.clientwidth  
     Page visible Area high:document.body.clientheight  
     Web page visible area wide: document.body.offsetwidth       (including edge width)   
     Page visible Area high:document.body.offsetheight      (including edge width)   
      Web page full text width:document.body.scrollwidth  
     Full text of the Web page high:document.body.scrollheight  
     Web pages are rolled High: document.body.scrolltop   
     pages are rolled left:document.body.scrollleft  
      Page body section:window.screentop  
     page body part left:window.screenleft  
     High:window.screen.height   for screen resolution
     Screen resolution wide:window.screen.width  
     screen available workspace height: window.screen.availheight  
     Screen available workspace width: window.screen.availwidth

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.