Resize a DIV to fill entire height of page? Please help

D

David Mark

Sorry for bumping such an old thread, just found this group.

If you want to do this via JS & CSS and (like me) you never know what
the
height of a completed dynamic page will be, then this is the way for
you. This
also handles if the body is smaller than the window, or larger to make
sure
that whichever is larger is completely filled.

The example below puts the color red over the entire page or viewport,
whichever is larger:

<script>

Oops. What type of script?
function test()
{
        var bodies = document.getElementsByTagName('BODY');

No test for this method? Not even an attempt at document.body?
        var body = bodies[0];
        var newNode = document.createElement('DIV');

        var ht = getWindowHeight();

Oh yeah, that global method.
        if (document.body.offsetHeight > ht)  

Oh brother.
                ht = document.body.offsetHeight;

Appalling. Two in one day using document.body.offset* to measure the
viewport. See the FAQ.
        var wd = getWindowWidth();

See above.
        if (document.body.offsetWidth > wd)
                ht = document.body.offsetWidth;

Same.

        newNode.style.height = ht + 'px';
        newNode.style.width = wd + 'px';
        newNode.style.backgroundColor = 'red';
        newNode.style.position = 'absolute';
        newNode.style.top = '0px';

Don't need units for 0.
        newNode.style.left = '0px';
        newNode.style.zIndex = '10000';
        newNode.innerHTML = '&nbsp;'
        body.appendChild(newNode);}

</script>

If you need more help, you may ping me at www dot perkiset dot
org/forum/

*** Sent via Developersdexhttp://www.developersdex.com***

I knew it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top