From: czechboy on
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 ;)
From: Thomas 'PointedEars' Lahn on
czechboy wrote:
> 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?

<http://groups.google.com/group/comp.lang.javascript/msg/29481241b1d86da3>
<http://www.jibbering.com/faq/#FAQ2_3>


PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee
From: Jorge on


czechboy wrote:
> 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.
From: Jorge on
On Jul 2, 6:47 pm, Jorge <jo...(a)jorgechamorro.com> wrote:
> 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);
>

Forget that. There's no need to move things around :

document.body.style.visibility= "none";
(document.getElementById('centerPage')).style.visibility= "visible";

--Jorge.
From: Henry on
On Jul 2, 5:57 pm, Jorge wrote:
<snip>
> document.body.style.visibility= "none";
<snip>

The specified values for the CSS 'visibility' property do not include
'none'. Such a declaration should be ignored, and if not ignored can
be expected to be subject to inconsistent handling.