[thelist] JavaScript for body wrapper to be 100% height

Jono Jono at charlestonwebsolutions.com
Wed Jan 10 06:28:36 CST 2007


Howard Jess wrote:
> jono at charlestonwebsolutions.com wrote:
>
>   
>> I know there are JavaScript solutions to make columns equal height; does
>> anybody have a JavaScript solution that can make a "wrapper" <div> 100% of
>> page's body width and height?
>>     
>
> OK; untested, no error-checks, completely off the top of my head:
>
>     window.onload = function() {
>         var newDiv = document.createElement('div'),
>             body = document.body;
>         newDiv.style.height = '100%';
>         newDiv.style.width = '100%';
>         while(body.firstChild) newDiv.appendChild(body.firstChild);
>         body.appendChild(newDiv);
>     }
>
>
> hj
>   
Thanks!

Question:
If this does work, is it possible to specify a class name (or ID) for 
the div that the js creates?  The reason I ask is that I may also 
want/need to also add a background image to the div that gets created by 
adding a style for the js-created <div> in my CSS.

I will test your js snippet today and report back.

-- 

*JONO YOUNG*
Designer | Developer | Illustrator
<http://www.charlestonwebsolutions.com>//




More information about the thelist mailing list