...

View Full Version : adding a layer to an existing document



freddybee
01-11-2003, 03:53 AM
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 ???

tempest1
01-11-2003, 04:08 AM
Uhhh.... WHAT??

freddybee
01-11-2003, 04:22 AM
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

tempest1
01-11-2003, 05:04 AM
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.

chrismiceli
01-11-2003, 05:35 AM
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


<a onclick="parent.framename.document.innerHTML+="Your new html here...">

freddybee
01-12-2003, 07:55 AM
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 ???

chrismiceli
01-12-2003, 06:49 PM
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


<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.

freddybee
01-13-2003, 08:07 PM
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 ??? :rolleyes:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum