Jump to content

Problema com rollovers


inextremis
 Share

Recommended Posts

Boas malta, tenho um problema com uns rollovers para um site. O que pretendo e que a imagem mude quando passo o rato por cima, quando carrego nela e quando movo o rato para fora dela.

Parece que o meu codigo não tá a funcionar mas não consegui encontrar nada de errado...


function addOnload(newFunction)
{
var oldOnload = window.onload;

if(typeof oldOnload == "function")
{
	window.onload = function()
	{
		if(oldOnload)
		{
			oldOnload();
		}
		newFunction();
	}
}
else
{
	window.onload = newFunction;
}
}

addOnload(rollovers);

function rollovers()
{
for (var i = 0; i < document.images.length; i++)
{
	if (document.images[i].parentNode.tagName == "A")
	{
		rolloverSetup(document.images[i]);
	}
}
}

function rolloverSetup(btn)
{
btn.outImage = new Image();
btn.outImage.src = btn.src;
btn.onmouseout = mouseOut;

btn.overImage = new Image();
btn.overImage.src = "images/topMenu/" + btn.id + "_down.png";
btn.onmouseover = mouseOver;

btn.downImage = new Image();
btn.downImage.src = "images/topMenu/" + btn.id + "_down.png";
btn.onmousedown = mouseDown;
}

function mouseOut()
{
this.src = this.outImage.src;
}

function mouseOver()
{
this.src = this.overImage.src;
}

function mouseDown()
{
this.src = this.downImage.src;
}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.