[Javascript] image rollover

Peter Brunone peter at brunone.com
Thu May 31 10:22:07 CDT 2001


    It sounds like you're changing the function to refer to only one image
at any given time.  Rather than hard-coding the image name, consider passing
it in along with the new image that you want it to be, like this:

 function SwapOut(fromImage, toImage) {
    fromImage.src = toImage.src; return true;
 }

and call it from the mouseover like this:

<A HREF="bio.html" onMouseOver="SwapOut(document.imageflip,Image2)">
<IMG NAME="imageflip" SRC="chairbw.jpg" WIDTH=80 HEIGHT=104
BORDER=0></A>


----- Original Message -----
From: <nina at cvzoom.net>
To: <Javascript at LaTech.edu>
Sent: Thursday, May 31, 2001 9:49 AM
Subject: [Javascript] image rollover


> I'm using an image rollover for 4 navigation images that switch
> back & forth from b&w to full color. The first one works fine,but
> when I add the other images, only the last one changes when I
> rollover any of the images.
>
> Here's the script:
>
> <SCRIPT LANGUAGE="JavaScript">
> <!-- hide from none JavaScript Browsers
> Image1= new Image(80,104)
> Image1.src = "chairx.jpg"
> Image2 = new Image(80,104)
> Image2.src = "chairbw.jpg"
>
> function SwapOut() {
> document.imageflip.src = Image2.src; return true;
> }
>
> function SwapBack() {
> document.imageflip.src = Image1.src; return true;
> }
>
> // - stop hiding -->
> </SCRIPT>
>
>
> Here's the command:
>
> <A HREF="bio.html" onMouseOver="SwapOut()" onMouseOut="SwapBack()">
> <IMG NAME="imageflip" SRC="chairbw.jpg" WIDTH=80 HEIGHT=104
> BORDER=0></A>
>
> After adding the additional b&w and color images,I replace the
> word "imageflip" in document.imageflip.src  and in the command <IMG
> NAME="imageflip" to correspond with each new image.
>
> What am I doing wrong? Is there another way to do this? Thanks!
>
>
>
>
>
>
>
>
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> http://www.LaTech.edu/mailman/listinfo/javascript
>





More information about the Javascript mailing list