(rollover.html file)
Untitled Document(script.js file)
// JavaScript Document
window.onload=rolloverinit;
function rolloverinit()
{
for(var i=0; i<document.images.length; i++)
{
if(document.images[i].parentNode.tagName==“A”)
{
setuprollover(document.images[i]);
}
}
}
function setuprollover(thisimage){
thisimage.outimage=new image();
thisimage.outimage.src=thisimage.src;
thisimage.onmouseout=rollout;
thisimage.overimage=new image();
thisimage.overimage.src="images/" + thisimage.id + "_on.jpg";
thisimage.onmouseover=rollover;
}
function rollout(){
this.src=this.outimage.src;
}
function rollover(){
this.src=this.overimage.src;
}