NEWSFEED



Rate BWD
@ HotScripts.com
Excellent
Very Good
Good
Fair
Poor

Scripts

Generators

Script Bits

Browser Window Dimensions

The following two functions return the available width and height inside the browser window. These functions can be used as variables and as the dimensions are calculated every time they are used, your script will always be using the current window size no matter what the user does to the window.

function winWid(){ return (moz) ? window.innerWidth : document.body.clientWidth; }
function winHei(){ return (moz) ? window.innerHeight : document.body.clientHeight; }

Results for this browser window:

Try resizing your window and refreshing this page to see other results

These functions require the Simple Browser Check to operate.

Example Script

// Simple Browser Check
var moz = (document.getElementById && !document.all) ? 1 : 0;

// Browser Window Dimensions
function winWid(){ return (moz) ? window.innerWidth : document.body.clientWidth; }
function winHei(){ return (moz) ? window.innerHeight : document.body.clientHeight; }

// Example Use
var displaywitdh = winWid();
var displayheight = winHei();
document.write('Width = '+displaywitdh+' : Height = '+displayheight);