[thelist] image swap works in Firefox and IE, not Chrome or Safari

Joel D Canfield joel at bizba6.com
Tue Feb 15 14:53:39 CST 2011

Testing on Win7 right now. This works in Firefox and IE, does nothing at all
in Chrome and Safari. The code validates in HTML Tidy but I'm always
suspicious of my javascript.

What's broken here?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "
<title>Image Swap Javascript Example</title>
<script type="text/javascript">
image1 = new Image()
image1.src = "papago_park_oasis.jpg"
image2 = new Image()
image2.src = "joel.jpg"
image3 = new Image()
image3.src = "tree_in_rock_2.jpg"
<div style="width:128px;float:right;border:1px solid
<a href="#" onclick="imageSwap.src='papago_park_oasis.jpg';">Oasis</a><br />
<a href="#" onclick="imageSwap.src='joel.jpg';">Joel</a><br />
<a href="#" onclick="imageSwap.src='tree_in_rock_2.jpg';">Tree</a>
<div style="float:left;width:512px;border:1px solid
<img src="joel.jpg" id="imageSwap" />

More information about the thelist mailing list