Forum Moderators: open
1. Does the script below get the actual browser window height?
2. If so, what syntax should I be using to launch another script if the vieable window area height is less than 500 pixels?
var winW, winH;
if (document.documentElement &&
document.documentElement.offsetHeight)//DOM1
{
winW = (window.innerWidth) ? window.innerWidth :
document.documentElement.offsetWidth - 20 ;
winH = ? window.innerHeight :
document.documentElement.offsetHeight - 4 ;
}
else if (document.body)// IE in old mode
{
winW = document.body.offsetWidth - 20;
winH = document.body.offsetHeight - 4;
}
else if (window.innerWidth)
{
winW = window.innerWidth ;
winH = window.innerHeight;
}
This is what I want to do but obviously the syntax is incorrect.
if (winH < = 500)
document.write('<script type="text\/javascript" language="javascript" src="minimize_div.js"><\/script>');
Thanks for your help.
How can I convert this or any other script to read:
If wH is less than 500px document write ('a script')?
<script language="JavaScript">
<!--
var wH = 480; // window defaults
var wW = 640; // window defaults
if (document.layers) {
wH = window.innerHeight;
wW = window.innerWidth;
// adjust for browser variation here
} else if (document.all) {
wH = document.body.clientHeight;
wW = document.body.clientWidth;
// adjust for browser variation here
}
// write embed tag here
document.write ('window height = ' + wH + '<BR>'); //sample return
document.write ('window width = ' + wW); //sample return
//-->
</script>