Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

« Newer Snippets
Older Snippets »
1 total  XML / RSS feed 

Prototype-based javascript window dimensions

Usage:
var dim = Position.GetWindowSize();
dim[0] is the window width
dim[1] is the window height

window can be specified, useful if you work with frames..

Position.GetWindowSize = function(w) {
        w = w ? w : window;
        var width = w.innerWidth || (w.document.documentElement.clientWidth || w.document.body.clientWidth);
        var height = w.innerHeight || (w.document.documentElement.clientHeight || w.document.body.clientHeight);
        return [width, height]
}

« Newer Snippets
Older Snippets »
1 total  XML / RSS feed