[Javascript] turning on scrollbars

Peter Brunone peter at brunone.com
Tue Jan 6 12:17:27 CST 2004


   FYI, sometimes the scrollbar (or, rather, the "socket" where the bar would be) shows in a script-opened window even if the content fits.  Then, when the content extends below, the bar pops in and scrolling begins.

Just my two cents for the "been there" account...

Peter

Original Message:
>From: Hassan Schroeder <hassan at webtuitive.com>

>Dan Anderson wrote:
>
>> Is there a way in javascript to turn on and off a scrollbar in a
>> document after its been loaded?
>
>Uh, not sure *why* you'd want to do this, since the scrollbar only
>appears if the page content won't fit within the viewport, but ...
>
>This works in Moz/Firebird 0.7, IE 5.5, Opera 7.22 (Win):
>
><script type="text/javascript">
>function init()
>{
>   /* these first two lines are only necessary for Moz; not sure
>    * why its computation of height differs, at least in my very
>    * brief test... alternate: see CSS below --
>    */	
>   document.getElementsByTagName("html")[0].style.height="100%";
>   document.getElementsByTagName("body")[0].style.height="95%";
>
>   document.getElementsByTagName("body")[0].style.overflow="hidden";
>}
>window.onload = init;
></script>
>
>You can also set the heights for Moz statically, as:
>
><style type="text/css">
>html {
>	height: 100%;
>	clip: auto;
>	}
>body {
>	height: 95%;
>	clip: auto;
>	}
></style>
>
>FWIW!
>-- 
>Hassan Schroeder ----------------------------- hassan at webtuitive.com
>Webtuitive Design ===  (+1) 408-938-0567   === http://webtuitive.com





More information about the Javascript mailing list