Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Javascript] image rollover
- From: javascript@xxxxxxxxxx (Peter Brunone)
- Subject: [Javascript] image rollover
- Date: Thu, 31 May 2001 10:22:07 -0500
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@xxxxxxxxxx>
To: <Javascript@xxxxxxxxxx>
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@xxxxxxxxxx
> http://www.LaTech.edu/mailman/listinfo/javascript
>
- References:
- [Javascript] image rollover
- From: javascript@xxxxxxxxxx
- [Javascript] image rollover
- Prev by Date: [Javascript] image rollover
- Next by Date: [Javascript] For/Next loop
- Previous by thread: [Javascript] image rollover
- Next by thread: [Javascript] For/Next loop
- Index(es):