hide whole body but one div

C

czechboy

Hi,
I can use document.body.style.display="none" to hide whole page but
then if I want to display one div only by
document.getElementById("centerPage").style.display="" it does not
work...

so is there any easy and fast way how to completely hide whole body
and to keep displayed one nested div only?

thanks ;)
 
T

Thomas 'PointedEars' Lahn

J

Jorge

czechboy said:
Hi,
I can use document.body.style.display="none" to hide whole page but
then if I want to display one div only by
document.getElementById("centerPage").style.display="" it does not
work...

so is there any easy and fast way how to completely hide whole body
and to keep displayed one nested div only?

No, because if the enclosing tag is hidden, all contained tags are
hidden as well.

I think you need to do something like this : :

var hiddenDiv, visibleDiv, e;

visibleDiv = document.getElementById('centerPage');
(hiddenDiv= document.createElement('div')).style.display= "none";

//Move all the body's elements to the hiddenDiv:
while (e= document.body.firstChild) {
hiddenDiv.appendChild(e);
}

//Now the body is empty.
//Insert centerPage into the body
document.body.appendChild(visibleDiv);
//Insert the hiddenDiv into the body.
document.body.appendChild(hiddenDiv);

--Jorge.
 
T

Thomas 'PointedEars' Lahn

Jorge said:
No, because if the enclosing tag is hidden, all contained tags are
hidden as well.

Obviously you don't know the `visibility' CSS property.


PointedEars
 
J

Jorge

Obviously you don't know the `visibility' CSS property.

Yes I do know style.visibility.
But I don't know how to "undo" a body.style.DISPLAY= "none" on an
inner element.

These are two different things, isn't it ?

Thanks,
--Jorge.
 
T

Thomas 'PointedEars' Lahn

Jorge said:
Yes I do know style.visibility.
But I don't know how to "undo" a body.style.DISPLAY= "none" on an
inner element.

These are two different things, isn't it ?

They are, but either you misread the OP's question or you missed the point
of my posting.


PointedEars
 

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

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top