Forum Moderators: open

Message Too Old, No Replies

Image does not display when Img created in Javascript

using IE

         

Serena

3:57 am on Jul 8, 2003 (gmt 0)



It seems to find the image file since the "no image found symbol" doesn't appear, but does not actually draw the image.

Note that if the img is created within an onclick of a <p>, it works fine, but not if it's created within the onclick of an <a>.

The browser is IE 6.0.28. In Netscape 6.1, the behavior is similar, except once the image file appears successfully once, then subsequent image creations with that file work fine. Would these be caching issues?

Here's a test .html file that exhibits the problem when executed from my localhost; it relies on one image file in the same directory.

Thanks very much for any help!


<html>
<head>
<script type="text/javascript">
function makeImage() {
var img = new Image()
img.src = "edit.gif"
img.border = 1
document.body.appendChild(img)
}
</script>
</head>

<body>
<p>
<a hRef="javascript: void 0" onclick="makeImage();">
Click to create image from "a tag onclick". Image does not appear
</a>
</p>
<p id="p1" onclick="makeImage();">
Click this to create image from "p tag onclick". Image appears
</p>
</body>
</html>

tedster

4:49 am on Jul 8, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Serena, welcome to WebmasterWorld

Both onclick events (a and p elements) are working on my computer -- IE 6.0.28 on Win98 SE.