Rollover2 - Single Line per Rollover
Simplest code I have found - after the JAVA script coe is entered - in the body, a single line is all you need per rollover. Works in IE but not in Netscape 4.x
Supports multiple images - but only 2 states. No image Preload) - so make sure to add your own preload code.
![]()
The Code
<script type="text/javascript">
function init() {
if (!document.getElementById) return
var imgOriginSrc;
var imgTemp = new Array();
var imgarr = document.getElementsByTagName('img');
for (var i = 0; i < imgarr.length; i++) {
if (imgarr[i].getAttribute('hsrc')) {
imgTemp[i] = new Image();
imgTemp[i].src = imgarr[i].getAttribute('hsrc');
imgarr[i].onmouseover = function() {
imgOriginSrc = this.getAttribute('src');
this.setAttribute('src',this.getAttribute('hsrc'))
}
imgarr[i].onmouseout = function() {
this.setAttribute('src',imgOriginSrc)
}
}
}
}
onload=init;
</script>
<img src="button1.jpg" hsrc="button2.jpg" width="160" height="35"><br>