Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

outerHTML equivalent in netscape.

Status
Not open for further replies.

inbaron

Programmer
Dec 9, 2002
22
0
0
US
I have an IMG "myImage" object which I want to copy into a div element "myDiv". It is very simple in IE

myDiv.innerHTML = myImage.outerHTML

Netscape does not support outerHTML. How can I do the same in Netscape?

Thanks
 
u may want to get its parent's inner html and replace the node's inner html with it:
<div id="MainDiv">
<div id="D1">
asdasd
</div>
</div>
<script>
TheHtml1=document.getElementById("D1").innerHTML
TheHtml2=document.getElementById("MainDiv").innerHTML
TheHtml2=TheHtml2.replace(TheHtml1,"")
alert(TheHtml2)
</script>



thats the closest i can get...

Known is handfull, Unknown is worldfull
 
Thanks, but this won't work. The parent node may include much more than just the image, and this is not under my control. For example, in the following, the parent is a <td> element but there is much more than the image inside.

<td><a>some link</a><img src = someSource propertyA = 'someProperty' propertyB = 'otherProperty'> some text </td>

 
include a dummy parent node:
<td><a>some link</a><div id="DummyNode"><img src = someSource propertyA = 'someProperty' propertyB = 'otherProperty'> some text</div> </td>


get the idea???

Known is handfull, Unknown is worldfull
 
What about:
Code:
// myDiv.innerHTML = "";
myDiv.appendChild( myImage.cloneNode( true ) );



 
Sorry vbkris, as I said, the html code is not under my control. I write the JS function to serve a general purpose and work on images identified by their id's, no matter how they are embedded in their html page.

The suggestion by vongrunt seems to be the right solution. Thanks, I'll try it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top