I\'m trying to clone an image in javascript, bud without loading a new one.
Normally new browsers will load an image once and there are several ways to use that image
javascript has provisions for this build in. here is code modified from Danny Goodman's Javascript Bible 2nd Ed p.498,500 for cacheing/preloading an image,
you can always use an array if you have a number of images to work with.
var img = new Array();
function initallimages(numImages, x, y) {
var x;
for (x=1; x <= numImages; x++) {
img['img' + x] = new Image(x,y);
img['img' + x].src = '/images/someimage.png';
}
}
function assignallimages(numImages) {
var x;
for (x=1; x <= numImages; x++) {
document.getElementById('img' + x).src = img['img'+x]['img' + x].src;
}
}
initallimages(3, 320, 240);
assignallimages(3);