Re: Javascript Swap Image

by "Emerson D. Champion" <champion(at)qis.net>

 Date:  Sun, 6 Jan 2002 20:25:49 -0500
 To:  "HWG-Languages" <hwg-languages(at)hwg.org>
 References:  qis
  todo: View Thread, Original
Well, it seems the use of "javascript:" in <a href="javascript:"
onClick="photoSwap(0);"> caused the problem. When I changed it to a # it
worked just fine.

Emerson Champion

----- Original Message -----
From: "Emerson D. Champion" <champion(at)qis.net>
To: "HWG-Languages" <hwg-languages(at)hwg.org>
Sent: Sunday, January 06, 2002 7:52 PM
Subject: Javascript Swap Image


First, the URL: http://www.standrewspasadena.com/photos.html

What's supposed to happen is that, when each link is clicked, the photo will
appear on the right. It works correctly when I use the preview function in
Dreamweaver. But when I upload the page & relevant images to the website,
they won't swap.

If you do view source in the browser, look for the JavaScript comment that
says, "Script to swap images into right table cell." Here's the short
version:

var photoArray= new Array()
photoArray[0]=new Image()
photoArray[0].src="images/photos/outside.gif"
function photoSwap(i)
 {
 document.churchPhoto.src=photoArray[i].src
 }

The image link is written like this:
<img src="images/photos/outside.gif" width="425" height="325"
name="churchPhoto">
hence the document.churchPhoto.src reference above, vice
document.images[i].src.

Each link is written like this:
<a href="javascript:" onClick="photoSwap(0);">Outside St. Andrew's</a>

There are 11 photos, so each item above is repeated 10 more times.

I've ensured I have the files uploaded to the correct directory; it's the
same directory structure as on my hard drive.
_____________________________________
Emerson D. Champion | champion(at)qis.net

HWG: hwg-languages mailing list archives, maintained by Webmasters @ IWA