bon
12-15-2003, 02:56 PM
Hi,
how may I add new objects that I create to my document using javascript and DHTML? I would like to do something like creating an Image and then displaying it on the page:
//Create image
var img = new Image();
img.src = "pics/blah_bla_.jpg";
//1) Make it pop up on page
document.images.length++;
document.images[document.images.length-1] = img;
//2) or, using some sort of overloaded write
document.write(img);
However, none of this seems to work.
How can I achieve this (can it be done)?
Comments and/or pointers to references will be greatly appreciated.
Kind regards,
Bon
PS. If it is done in a way similar to 1), how do I control the position of the newly created image?
PPS: I would like to be able to make an arbitrary number of images this way, so I can't just make some
<IMG ID=dummy>
and then later on
document.images[someNum].src = "/path/pic.jpg";
how may I add new objects that I create to my document using javascript and DHTML? I would like to do something like creating an Image and then displaying it on the page:
//Create image
var img = new Image();
img.src = "pics/blah_bla_.jpg";
//1) Make it pop up on page
document.images.length++;
document.images[document.images.length-1] = img;
//2) or, using some sort of overloaded write
document.write(img);
However, none of this seems to work.
How can I achieve this (can it be done)?
Comments and/or pointers to references will be greatly appreciated.
Kind regards,
Bon
PS. If it is done in a way similar to 1), how do I control the position of the newly created image?
PPS: I would like to be able to make an arbitrary number of images this way, so I can't just make some
<IMG ID=dummy>
and then later on
document.images[someNum].src = "/path/pic.jpg";