Why would you want to do that. The document.images array is an array of
elements that are _already_ on the page.
If you which to pre-load graphics you can just create new image objects:
for (var i= 1 ; i < 6; i++) {
img = new Image();
img.src = cards1[i] + '.gif';
}
Or, you can put them in an array:
var cardImgs = new Array(6);
for (var i= 1 ; i < 6; i++) {
cardImgs[i] = new Image();
cardImgs[i].src = cards1[i] + '.gif';
}
Or you can add them to a page by using DOM (in the onload):
document.onload = function() {
for (var i= 1 ; i < 6; i++) {
var myImg = document.createElement('img');
myImg.src = cards1[i] + '.gif';
document.body.appendChild(myImg);
}
}
Good luck,
Vincent
wrote:
> I am trying to have
> "window.document.images[i].src=''+cards1[i]+'.gif'" work in a loop just
> as "document.write(<img src="'+cards[i]+'">); does, but it does not
> seem to be within Javascript's ability.
>
> The following works:
>
> for(var i=1;i<6;i++){
>
> document.write('<td><img src="'+cards[i]+'.gif"></td>');
>
> }
>
> but this one does not:
>
> for(var i=1;i<6;i++){
>
> window.document.images[i].src=''+cards1[i]+'.gif";
>
> }
>
> Any help is greatly appreciated,
> Thanks.
>