hi all:
I am trying to make some javascript buttons and this the first time I am attempting it. When I make the buttons individually, they work, but when I put the three buttons in the same web page, the first two buttons load the first image correctly, but then only something goes wrong. The home button changes to look like the contact button and the down image stay as the contact image. The product image locks as the product image and doesn't switch to the down image. Finally, when I click the contact image, the home image activates as the down image. What in the world did I mess up on? Here is a section of code that I used.
I am trying to make some javascript buttons and this the first time I am attempting it. When I make the buttons individually, they work, but when I put the three buttons in the same web page, the first two buttons load the first image correctly, but then only something goes wrong. The home button changes to look like the contact button and the down image stay as the contact image. The product image locks as the product image and doesn't switch to the down image. Finally, when I click the contact image, the home image activates as the down image. What in the world did I mess up on? Here is a section of code that I used.
Code:
<img
name="jsbutton" src="images/home.jpg" width="230" height="35" border="0"
alt="javascript button"></a>
<script language="JavaScript">
upImage = new Image();
upImage.src = "images/home.jpg";
downImage = new Image();
downImage.src = "images/home2.jpg"
normalImage = new Image();
normalImage.src = "images/home.jpg";
function changeImage()
{
document.images["jsbutton"].src= upImage.src;
return true;
}
function changeImageBack()
{
document.images["jsbutton"].src = normalImage.src;
return true;
}
function handleMDown()
{
document.images["jsbutton"].src = downImage.src;
return true;
}
function handleMUp()
{
changeImage();
return true;
}
</script>
<br>
<a href="products.htm"
onMouseOver="return changeImage()"
onMouseOut= "return changeImageBack()"
onMouseDown="return handleMDown()"
onMouseUp="return handleMUp()"
><img
name="jsbutton" src="images/products.jpg" width="230" height="35" border="0"
alt="javascript button"></a>
<script language="JavaScript">
upImage = new Image();
upImage.src = "images/products.jpg";
downImage = new Image();
downImage.src = "images/products2.jpg"
normalImage = new Image();
normalImage.src = "images/products.jpg";
function changeImage()
{
document.images["jsbutton"].src= upImage.src;
return true;
}
function changeImageBack()
{
document.images["jsbutton"].src = normalImage.src;
return true;
}
function handleMDown()
{
document.images["jsbutton"].src = downImage.src;
return true;
}
function handleMUp()
{
changeImage();
return true;
}
</script>
<a href="contact.htm"
onMouseOver="return changeImage()"
onMouseOut= "return changeImageBack()"
onMouseDown="return handleMDown()"
onMouseUp="return handleMUp()"
><img
name="jsbutton" src="images/contact.jpg" width="230" height="35" border="0"
alt="javascript button"></a>
<script language="JavaScript">
upImage = new Image();
upImage.src = "images/contact.jpg";
downImage = new Image();
downImage.src = "images/contact2.jpg"
normalImage = new Image();
normalImage.src = "images/contact.jpg";
function changeImage()
{
document.images["jsbutton"].src= upImage.src;
return true;
}
function changeImageBack()
{
document.images["jsbutton"].src = normalImage.src;
return true;
}
function handleMDown()
{
document.images["jsbutton"].src = downImage.src;
return true;
}
function handleMUp()
{
changeImage();
return true;
}
</script>