Forum Moderators: open

Message Too Old, No Replies

DOM Issue with FireFox and IE

document.image. issue with firefox

         

housto

8:15 pm on Feb 15, 2006 (gmt 0)

10+ Year Member



At least i think it is.

I have a JS function that will preload my images for a slideshow, and then i want to show the first image of the slide show when the page is opened. I can get this working fine in IE, but when viewing in Firefox, and just cant get it to work.

The Javascript function that is doing the preload:

function preloadimages(){
for (i=0;i<preloadimages.arguments.length;i++){
myimages[i] = new Image()
myimages[i].src = preloadimages.arguments[i]
}
}

preloadimages("images/image0.jpg")

and where I am calling the image in the HTML.

<td height="310" valign="top" align="center">
<a href="javascript:warp()"><img id="targetimage" alt="click to return to portfolio" src="javascript:document.getElementById('targetimage').src=myimages[0].src"></a>
</td>

I have also tried it this way, and it also didnt work.

<td height="310" valign="top" align="center">
<a href="javascript:warp()"><img id="targetimage" alt="click to return to portfolio" src="javascript:document.images.targetimage.src=myimages[0].src"></a>
</td>

Any help would really be appreciated

Bernard Marx

10:04 pm on Feb 15, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Javscript protocol used in an image src attribute?!
Unconventional. I'm not surprised Moz doesn't like it.

You could just hard code the first image path into the src instead, or..

<td height="310" valign="top" align="center">
<a href="#" onclick="warp();return false;"><img id="targetimage" alt="click to return to portfolio"></a>
</td>
<script type="text/javascript">
document.getElementById("targetimage").src=myimages[0].src;
</script>

housto

11:45 pm on Feb 15, 2006 (gmt 0)

10+ Year Member



that worked a treat. thanks for you help, it really is appreciated.