HI there, I have done a little work on a simple script to change images on mouse over and on mouse off. It was meant to be a very simple one but it is not working and I am not quite sure why.
here's the coplete html and script code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Javascript test</title>
<script type = "text/javascript">
<!--
function change_mouseon('image')
{
document.images['image'].src = image + "_in.jpg";
}
function change_mouseoff('image')
{
document.images['image'].src = image + "_out.jpg";
}
//-->
</script>
</head>
<body>
<div>
<a href = "#" onmouseover = "change_mouseon('image_1')" onmouseout = "change_mouseoff('image_1')"><img src = "image_1_out.jpg" alt = "" style = "border:none;" name = "image_1"></a>
<a href = "#" onmouseover = "change_mouseon('image_2')" onmouseout = "change_mouseoff('image_2')"><img src = "image_2_out.jpg" alt = "" style = "border:none;" name = "image_2"></a>
</div>
</body>
</html>
I would like to go through it just to make sure I have done it correctly:
1)the first image link has 2 functions change_mouseon('image_1')
and change_mouseoff('image_1')
passing a parameter to the function. then image1
gets passed to the first function therefore document.images['image'].src = image + "_in.jpg";
becomes document.images['image_1'].src = image_1 + "_in.jpg";
Similarly for the second function and the the other image. I named my images as follow:
image_1_in.jpg
image_1_out.jpg
image_2_in.jpg
image_2_out.jpg
and I have attached them too, they are very small files
Can't quite understand what I got wrong and when I hover on the images they don't change
thanks