Reprint: JQuery Get screen height, width

Source: Internet
Author: User

Do mobile Web development to do browser compatibility, so found on the Internet some summary under.

Alert ($ (document.body). Height ());
Alert ($ (document.body). Outerheight (True));  
Alert (document). width ());
Alert ($ (document.body). width ());
Alert ($ (document.body). Outerwidth (True));  
Gets the height and width of the page
function GetPageSize () {
    var xscroll, Yscroll;
    if (window.innerheight && window.scrollmaxy) {
        Xscroll = window.innerwidth + Window.scrollmaxx;
        Yscroll = Window.innerheight + window.scrollmaxy;
    else {
        All but Explorer Mac    
            Xscroll = Document.body.scrollWidth;
            Yscroll = Document.body.scrollHeight;
        Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari    
            Xscroll = Document.body.offsetWidth;
            Yscroll = Document.body.offsetHeight;
        }
    }
    var windowwidth, WindowHeight;
    All except Explorer    
        if (document.documentElement.clientWidth) {
            WindowWidth = Document.documentElement.clientWidth;
        else {
            WindowWidth = Self.innerwidth;
        }
        WindowHeight = Self.innerheight;
    else {
        Explorer 6 Strict Mode    
            WindowWidth = Document.documentElement.clientWidth;
            WindowHeight = Document.documentElement.clientHeight;
        else {
            Other explorers    
                WindowWidth = Document.body.clientWidth;
                WindowHeight = Document.body.clientHeight;
            }
        }
    }       
    For small pages and total height less then height of the viewport    
    if (Yscroll < WindowHeight) {
        PageHeight = WindowHeight;
    else {
        PageHeight = Yscroll;
    }    
    For small pages and total width less then width of the viewport    
    if (Xscroll < windowwidth) {
        PageWidth = Xscroll;
    else {
        PageWidth = WindowWidth;
    }
    New Array (PageWidth, PageHeight, WindowWidth, windowheight);
    return arraypagesize;
}
scroll bar
Document.body.scrollTop;
$ (document). ScrollTop ();


Copyright, welcome reprint, reproduced Please indicate the source, thank you

Reprint: JQuery Get screen height, width

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.