Client Window Size | JavaScriptSource

Client Window Size

Konstantin Jagello Jul 7, 2008


Use this snippet to obtain the width and height of the visitor's client window. This is a much better method than getting the resolution as this is the actual size of the window displaying the Web page.



var width = document.compatMode=='CSS1Compat' &&

var height = document.compatMode=='CSS1Compat' &&

document.write("Your client window width is: "+width+"<br>
  Your client window height is: "+height+"");

Source Code

Paste this source code into the designated areas.

External file

Paste this code into an external JavaScript file named: clientWindowSize.js


Paste this code into the HEAD section of your HTML document.

Leave a Response


Your question is beyond the scope of these comments. You will need to post it over on [a href=""]the JavaScript forum[/a]. Thanks!

Lee Oct 31, 2008

This is a potentially useful script---how would I apply it to resize the appearance of a Web page to match the client's window?

Michael Sadie Jul 16, 2008