Aspasia. 470?-410 BCE.

Image effects and simple rollovers

Detecting the click:

type example script comments
a clickable
image
<img src="i1.jpg" onclick="alert('orange?');"> won't work in old browsers since image doesn't handle click
a clickable image <a href="#" onclick="alert('green?');">
<img src="i2.jpg"></a>
will work in old browsers since image is nested in link which handles event. Note border around image. May scroll page.
a clickable image <a href="#" onclick="alert('greener?');">
<img src="i3.jpg" border="0"></a>
should work in all browsers; eliminates border around image; may scroll page.

Events other than clicks:

type example script comments
mouse enters the image <img src="i1.jpg" onmouseover="alert('orange?');"> won't work in old browsers since image doesn't handle event
mouse enters; mouse leaves. <img src= "i4.jpg"onmouseover="src='i3.jpg';"
onmouseout="src='i4.jpg';">
won't work in old browsers.
mouse enters; mouse leaves. <a href= "#"onmouseover="h1.src='i3.jpg'"
onmouseout="h1.src='i2.jpg'">
<img src="i2.jpg" name="h1" border="0">
</a>
a basic rollover from one image to another; should be same in all browsers. Since events are managed outside img tag, image is named to provide a handle for reference.
mouse is depressed; mouse is released. <a name="b" href= "#b"  onmousedown="h2.src='i4.jpg'"
onmouseup="h2.src='i3.jpg'">
<img src="i3.jpg" name="h2" border="0">
</a>
make sure the image has a different name than above; else see below. Onmouseup triggers scrolling. Local anchor restricts range of scroll.
mouse enters; wrong image is rolled <a href= "#"onmouseover="h2.src='i4.jpg'"
onmouseout="h2.src='i5.jpg'">
<img src="i5.jpg" name="h3" border="0">
</a>
here's what happens if wrong image name is used. Though mouseover and mouseout are planned for, click causes scrolling.
mouse enters; mouse leaves; no click. <a href= "javascript:R('h6',file);"onmouseover="file='i5.jpg';R('h6',file);"
onmouseout="file='i2.jpg';R('h6',file);">
<img src="i2.jpg" name="h6" border="0"></a>
A way to how Adobe Image Ready handles rollovers.
<script>
function R(I,S){
document.images[I].src=S;
}</script>