Hi guys I have a simple rollover onmouseover effect, I have tried several scripts but none of them work, can anyone tell me why?`
javascript:
<script language="JavaScript" type="text/javascript">
<!--
if (document.images) {
homebuttonup = new Image();
homebuttonup.src = "./images/gym-light.png";
homebuttondown = new Image();
homebuttondown.src = "./images/buttonright.png";
}
function buttondown(buttonname) {
if (document.images) {
document[buttonname].src = eval(buttonname + "down.src");
}
}
function buttonup(buttonname) {
if (document.images) {
document[buttonname].src = eval(buttonname + "up.src");
}
}
// -->
</script>
and link:
<a href="index.html" onmouseover="buttondown('homebutton')" onmouseout="buttonup('homebutton')">
<img id='Img4Inner' name="homebutton" src='./images/gym-light.png' alt="" />
</a>
Your code works
Here is however a more unobtrusive version
http://jsfiddle.net/mplungjan/927nN/
**UPDATE 2 (last one lol) ** you currently have the onmouseout and onmouseover on the a tag, move them to the image tag and it will work:
you're code:
Working code:
Update: because you're invoking the functions on the anchor tags they need to have a height and a width similar to the following (place your height and width accordingly):
and I"m out...
I just used firebug, edited the HTML with the height and width and it worked fine :
)
and while I"m sure that will solve the problem.. the doctype is set to <!doctype html> and should be something like what's here (LINK)
if you would've implemented the below approach, the image would have a height and width, and since that is the image that is being targeting, might make more sense..
http://jsfiddle.net/ETHaM/2/