Finding the Browser's Window Size

© 2011, Martin Rinehart

Suppose you want to divide your browser window into quarters, two by two. Sounds simple, right? This bit of code should explain itself.

/** Return size of browser's client area. */
function client_size() {
    if ( window.innerWidth ) {
            return [ window.innerWidth,
                    window.innerHeight ]; }

    return [ document.body.offsetWidth,
            document.body.offsetHeight ];
}

Yes, that's standards-based browsers first, IE second. If you really want to support older IEs, ask Google for additional answers.

Feedback: MartinRinehart at gmail dot com

# # #