PDA

View Full Version : Get FF innerHeight without scrollbar height



xjj168
03-30-2007, 02:00 PM
How do get innerHeight in FireFox without scrollbar height? Any suggestion

jscheuer1
03-30-2007, 03:31 PM
Simple answer:


document.body.clientHeight

But, that will do it in Opera 9 too as well as in IE without a DOCTYPE but, if you want it for all three with or without DOCTYPE and have it degrade where not supported:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
function getHeight(){
function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat" && !window.opera)? document.documentElement : document.body;
}
if(iecompattest().clientHeight)
return iecompattest().clientHeight;
else
return null;
}
</script>
</head>
<body>
<p style="width:125%;">&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<input type="button" onclick="alert(window.innerHeight);"><br>
<input type="button" onclick="alert(getHeight());"><br>
</body>
</html>

xjj168
03-30-2007, 04:12 PM
Thanks, John.