Roll over one of our images.
<html>
<head>
<title>JavaScript Unleashed</title>
<script type="text/javascript" language="JavaScript1.2">
<!--
var overImg = new Array();
overImg[0] = new Image(24,24);
overImg[1] = new Image(24,24);
var defaultImg = new Array();
defaultImg[0] = new Image(24,24);
defaultImg[1] = new Image(24,24);
overImg[0].src = "http://www.java2s.com/style/logo.png";
overImg[1].src = "http://www.java2s.com/style/logoRed.png";
defaultImg[0].src = "http://www.java2s.com/style/logo.png";
defaultImg[1].src = "http://www.java2s.com/style/logoRed.png";
function rollImage(img,type){
switch(type){
case "over":
document.images[img].src = overImg[img].src;
break;
case "out":
document.images[img].src = defaultImg[img].src;
break;
}
}
//-->
</script>
</head>
<body>
<table>
<tr>
<td align="center">
<a href="javascript:void(0)"
onmouseout="rollImage('0','out')"
onmouseover="rollImage('0','over')">
<img border="0" src="back.gif" width="24" height="24" alt="Back">
</a> </td>
<td align="center">
<a href="javascript:void(0)"
onmouseout="rollImage('1','out')"
onmouseover="rollImage('1','over')">
<img border="0" src="forward.gif" width="24" height="24"
alt="Forward"></a>
</td>
</tr>
</table>
</body>
</html>
Related examples in the same category