[Javascript] Writing <img> to <div>

Andrew Gibson andyg at ihug.co.nz
Sat Jun 8 17:46:03 CDT 2002


I've having a problem when writing to a <div> getting content from another
<div> when an image is involved.

Like so:

<div id=one>
Here is my image <br><img src=myImage.gif>
</div>
<div id=two>
</div>

<script>
var txt=document.getElementById("one").innerHTML
document.getElementById("two").innerHTML=txt
</script>

The script doesn't always display the image...yet when I right click and
select Show picture, it shows it....almost as if the image is not downloaded
by the time the div .innerHTML is written it won't display the image?


Andrew Gibson






More information about the Javascript mailing list