"Lasse Reichstein Nielsen" <lr*@hotpop.com> wrote in message
news:3c**********@hotpop.com...
<snip>
You can do this:
---
var img = new Image();
img.src=fred;
document.body.appendChild(img);
---
but that displays the image at the end of the document.
On some of the more recent browsers new Image() is very like
document.createElement('img') and does return an object with all of the
characteristics of an IMG element. But they are not required to be
equivalent, and I don't think I would recommend new Image() over
createElement (if available, so probably whenever appendChild is
available (except for possible problems with IE 4 and late Opera 6
versions [1])). On IceBrowser, for example, creating and appending an
IMG element will work but the global Image constructor is a functionless
dummy.
Richard.
[1] For reasons that have never become clear Opera 6 (at least the later
versions) has a document.createElement function, but as it is not
possible to dynamically alter the DOM in the browser on Opera 6 there
doesn't seem much point in having the function (and I don't think that
it is functional). IE 4 has both document.createElement and appendChild
methods on its elements but they are pre-W3C DOM methods and cannot be
used in the same way as the W3C versions.