Please this code is not working for rollover and rollout events ?

(rollover.html file)

Untitled Document Button1   button2

(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;
}

I would recommend using jQuery.

Sponsor our Newsletter | Privacy Policy | Terms of Service