Forum Moderators: open
Ok, maybe that's a bit extreme... after several hours of kicking its teeth in, it IS cooperating wonderfully in IE5 and Netscape 4.79... its centered to within a pixel's precision, and does not change no matter how you manipulate the window.
BUT... this does not remain true for Netscale 6.2.1 in which the menu ONLY appears to be correctly centered as long as the up-down scrollbar is present... meaning for people with large monitors, they'd have to shrink the window down enough so that the scrollbar appears before the menu is correctly aligned.
Help? My question is... does anyone have a notion on DETECTING the current state of a scrollbar? Or, does anyone have a notion on forcing said scrollbar into existance, regardless of the length of content?
In either case, I could put this puppy to rest.
Or perhaps, is there a way to detect document overflow (i.e., the need for the scrollbar to have ever appeared to begin with.) I saw one artcile on it, but repeated tests resulted in nothing.
<html>
<head>
<script type='text/javascript'>
window.onload = function() {
updateForm();
}
function updateForm() {
var d = // document height
document.height // moz, nn4
¦¦ document.body.scrollHeight // ie
¦¦ document.body.style.pixelHeight; // opera
var w = // window height
window.innerHeight // moz, nn4, opera
¦¦ document.body.clientHeight; // ie
var f = document.forms.f1; // form
f.dh.value = d;
f.wh.value = w;
f.vsb.value = d > w ? 'true' : 'false';
setTimeout('updateForm()', 500);
}
</script>
</head>
<body>
<h3>Vertical Scrollbar Detection</h3>
<p>Resize the window vertically and watch the values.</p>
<form name='f1'>
<p>document height <input name='dh' type='text'></p>
<p>window height <input name='wh' type='text'></p>
<p>document height > window height <input name='vsb' type='text'></p>
</form>
<p>Theoretically, a vertical scrollbar is present when
<i>document height > window height</i>. But my tests show that
this is not exactly true for Mozilla0.9.7, but was true for IE5.01,
was true for Netscape4.79, and was true for Opera6.01 (all on Win2K).
For Mozilla, window.innerHeight seems to include the status bar
(23 pixels on my test). Perhaps I did not use the most
appropriate properties in the script - any feedback is welcome.</p>
<p>This is the last paragraph in the body element.</p>
</body>
</html>
<P> </P>
just before the </BODY> tag
cheers
Dave
can javascript edit css depending on browser type?
Yes. The details are probably too extensive to go into here, but there are numerous tutorials on the subject. I favor Peter Paul Koch's approach to browser detection (do a Google search to look up his Javascript section).
Basically, use yer favorite browser detection script, and set the body.style.overflow appropriately.