Sometimes it is useful to obtain the dimensions of the users browser window. The following JavaScript code can be used to obtain the height and width :
<script type="text/javascript">
<!--
var v_width;
var v_height;
// Standards compliant browsers (mozilla/netscape/opera/IE7)
// use window.innerWidth and window.innerHeight
if (typeof window.innerWidth != 'undefined')
{
v_width = window.innerWidth,
v_height = window.innerHeight
} else if (typeof document.documentElement != 'undefined'
&& typeof document.documentElement.clientWidth != 'undefined'
&& document.documentElement.clientWidth != 0) {
// IE6 in standards compliant mode
// (i.e. with a valid doctype)
v_width = document.documentElement.clientWidth,
v_height = document.documentElement.clientHeight
} else {
// older versions of IE
v_width = document.getElementsByTagName('body')[0].clientWidth,
v_height = document.getElementsByTagName('body')[0].clientHeight
}
document.write('<p>Viewport size : ' +
v_width + 'x' +
v_height + '</p>');
//-->
</script>