Hi!
Have read your thread and tried everything. But still can't make it work.
I can get the first image up but not the second or the mouseOver.
My code is:
<script language="javascript1.5">
Rollimage = Rollimage = [];
Rollimage[0] = new Image(200,150)
Rollimage[0].src = "automotive/images/mustangbefore.jpg"
Rollimage[1] = new Image(200,150)
Rollimage[1].src = "automotive/images/mustangafter.jpg"
function SwapBack(image, number){
document[image].src = Rollimage[number].src;
return true;
}
function SwapOut(image, number) {
document[image].src = Rollimage[number].src;
return true;
}
</script>
//-->
</script>
</head>
<body bgcolor="#FFFFFF" alink="#008000" vlink="#800080" link="#0000FF" text="#000000" onload="preloadImages()"><p>
<p>
<a href="#" onmouseover="SwapOut('mustangafter', 0)" onmouseout="SwapBack(mustangbefore)"><img name="mustang" alt="Mustang" src="images/mustangbefore.jpg" /></a>
</body>
</html>
The page is at www.sodablast.net.au/automotive/test.html
The images are in the automotive sub-directory at #images.
Apologies for being a nuisance, but I can't make it work.
Looks like a good script.
Any help appreciated.
Gift in mail from Down Under (Australia) in appreciation if you can help me out.
regards
Geoff A Hinde
Some lines within your code call my attention:
Rollimage = Rollimage = [];
should be:
Rollimage = new Array();
then the two lines with " " are meaningless, please remove them.
The two functions (SwapOut and SwapBack) are exactly he same code... Why to have them dplicated instead of use just one of them?
Also, you are using only one image in your document, with the name attribute of 'mustang', but you are trying to find images with the names of "mustangbefore" and "mustangafter".
The call to any of the functions that you have, should be something like:
onmouseover="SwapOut('mustang', 0)"
where 'mustang' is the name of the image (within the HTML document body) that you want to alter, and 0 is the number of the matrix index that you want to place in.
Within the functions that you have, you attempt to address the image using:
document[image].src = Rollimage[number].src;
and, in order to properly address the image that you want to change, the line should be:
document.getElementById(image).src = Rollimage[number].src;