Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New Coder
    Join Date
    Jun 2002
    Location
    Paris, France
    Posts
    35
    Thanks
    0
    Thanked 0 Times in 0 Posts

    adding a alyer to an existinfg document

    I would like to add a layer to an existing document.

    I could have use innerHTML and create a layer in each and every page of my site but I guess that there is a fonction that could add HTML to a document without loosing the existing content ...

    Any idea ???
    [color=dark blue]Freddy Bee[/color]

  • #2
    New Coder
    Join Date
    Nov 2002
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Uhhh.... WHAT??

  • #3
    New Coder
    Join Date
    Jun 2002
    Location
    Paris, France
    Posts
    35
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you )))

    Sorry if my question was not clear enough (english is not my mother tongue as you can read) ...

    I do have a site whith frames
    In the bootom frame, I have a link.

    I would like that link to show a layer in the main frame.

    That layer is not define <div id=layer1></div> in the pages that goes in the main frame (otherwise the solution should have be to use GetElementbyId('layer1').innerHTML='bla bla bla'

    But the layer is not defined.

    I would like to use something to add the HTML of the div and its content to an existing page.

    Is that clear and have you got any idea.

    I guess that insertAdjacentHTML is perhaps a clue but I do not know how to use it well and it is said that you have to include the DEFER attribute in the script element when using this method (????).

    Any idea
    [color=dark blue]Freddy Bee[/color]

  • #4
    New Coder
    Join Date
    Nov 2002
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts
    lets say the top frame is named in the html, top_frame.... for simplicity. Heres what i got off the top of my head...


    <a onclick="top_frame.body.innerHTML+='Your new html here...';">Testing...</a>

    DISCLAIMER: I have never used += before. I hope this works.

  • #5
    Regular Coder
    Join Date
    Sep 2002
    Location
    Louisiana
    Posts
    576
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ask one of the mods or beetle about dom, i am don't know it that well, but there is like
    document.createElement("div");
    something like that, or just use innerHtml.
    document.innerHTML += "<div id='layer1'>hi</div>";
    <edit>inner html like in post above, i do beleive it is correct syntax except
    Originally posted by tempest1
    <a onclick="top_frame.body.innerHTML+='Your new html here...';">
    should be
    Code:
    <a onclick="parent.framename.document.innerHTML+="Your new html here...">
    Last edited by chrismiceli; 01-11-2003 at 05:38 AM.

  • #6
    New Coder
    Join Date
    Jun 2002
    Location
    Paris, France
    Posts
    35
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you.

    As I said .... innerHTML replace the existing HTML in the body of the document when I just want to append something ...

    Any other idea ???
    [color=dark blue]Freddy Bee[/color]

  • #7
    Regular Coder
    Join Date
    Sep 2002
    Location
    Louisiana
    Posts
    576
    Thanks
    0
    Thanked 0 Times in 0 Posts
    that is why you should use +=
    that way it adds whatever html you want to something. if it be your body, or a div you made. you could do it like this for your porpuses
    Code:
    <html>
    <head>
    <title>hi</title>
    <script type="text/javascript">
    function addLayer() {
    document.getElementById("hi").innerHTML = "<div>hi</div>";
    }
    </script>
    </head>
    <body>
    this will stay here
    <div id="hi"></div>
    </body>
    </html>
    that creates a nested layer, but should work for your porpuses, if not, you can do as i said, document.innerHTML += "<div></div>"; but that would be after the </body> tags.

  • #8
    New Coder
    Join Date
    Jun 2002
    Location
    Paris, France
    Posts
    35
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you very much ....

    In fact it was working from the begining but you wrote

    document.innerHTML +=

    when I should have read

    document.body.innerHTML +=


    Thank you again for you valuable help ...


    Does that works with Netscape too ???
    [color=dark blue]Freddy Bee[/color]


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •