Re: hide whole body but one div

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jorge

    Re: hide whole body but one div

    On Jul 2, 6:47 pm, Jorge <jo...@jorgecha morro.comwrote:
    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.getEle mentById('cente rPage');
    (hiddenDiv= document.create Element('div')) .style.display= "none";
    >
    //Move all the body's elements to the hiddenDiv:
    while (e= document.body.f irstChild) {
      hiddenDiv.appen dChild(e);
    >
    }
    >
    //Now the body is empty.
    //Insert centerPage into the body
    document.body.a ppendChild(visi bleDiv);
    //Insert the hiddenDiv into the body.
    document.body.a ppendChild(hidd enDiv);
    >
    Forget that. There's no need to move things around :

    document.body.s tyle.visibility = "none";
    (document.getEl ementById('cent erPage')).style .visibility= "visible";

    --Jorge.
  • Evertjan.

    #2
    Re: hide whole body but one div

    czechboy wrote on 02 jul 2008 in comp.lang.javas cript:
    Thanks for your answers... I will study links you provided me.
    >
    What I want to do is to load some page (like google.com) hide it and
    then display only one div.
    >
    Problem with visibility is that hidden elements still keep their
    places... for that display="none" looks much better, but unfortunately
    does not work with nested elements to be visible
    ============= test.html =========
    <body>
    a
    <div id=b>
    b
    </div>
    c
    </body>

    <script type='text/javascript'>
    document.body.i nnerHTML =
    document.getEle mentById('b').i nnerHTML;
    </script>
    =============== =============== ===

    tested in IE7

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)

    Comment

    • Dr J R Stockton

      #3
      Re: hide whole body but one div

      In comp.lang.javas cript message <8282d067-ae06-4371-ae53-aeb17d248215@e5
      3g2000hsa.googl egroups.com>, Wed, 2 Jul 2008 14:15:42, czechboy
      <oldrich.svec@g mail.composted:
      >
      >What I want to do is to load some page (like google.com) hide it and
      >then display only one div.
      If you really mean that, I see no good reason for loading the other
      material.

      If you want to have a number of divs, only one visible at a time but the
      choice changing, then maybe, in pseudo-script :

      <body>
      <div ID=fred</div>
      <div hidden>
      <div ID=ATextA </div>
      <div ID=BTextB </div>
      <div ID=CTextC </div>
      </div>
      </body>

      and use code to copy or move, each time, the div containing the required
      text into and maybe out of div fred. Alternatively, the mobile material
      could be literal JavaScript strings.

      --
      (c) John Stockton, nr London, UK. ?@merlyn.demon. co.uk Turnpike v6.05 MIME.
      Web <URL:http://www.merlyn.demo n.co.uk/- FAQish topics, acronyms, & links.
      Proper <= 4-line sig. separator as above, a line exactly "-- " (SonOfRFC1036)
      Do not Mail News to me. Before a reply, quote with ">" or "" (SonOfRFC1036)

      Comment

      • czechboy

        #4
        Re: hide whole body but one div

        If you really mean that, I see no good reason for loading the other
        material.
        you are right. But then I can not guarantee complete functioning of
        the code, because some of the necesary javascript might have been
        erased.

        I think I will use display="none" on separate divs ;)

        thanks for your help

        Comment

        Working...