|
I hope i'm at the right place here. I'm new in JavaScript.
In my studies i stumbled over a code that i just can't get working.
I need to create a simple rollover effect with this JavaScript code:
JavaScript:
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 = "http://www.webmaster-talk.com/images/" + thisImage.id + "_on.gif";
thisimage.onmouseover = rollOver;
}
function rollOut() {
this.src = this.outImage.src;
}
function rollOver() {
this.src = this.overImage.src;
}
HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="script11.js"></script>
<link rel="stylesheet" rev="stylesheet" href="style007.css" />
</head>
<body>
<a href="css001.html"><img src="http://www.webmaster-talk.com/images/leave01_off.gif" alt="leave01" id="leave01" /></a>
<a href="css001.html"><img src="http://www.webmaster-talk.com/images/leave02_off.gif" alt="leave02" id="leave02" /></a>
</body>
</html>
The images are in the right folder. They appear as buttons, but i don't get
the rollover effect!
I was sitting on that thing all day, but i just can't figure it out.
Where is the error?
Thanks so much for you help!
honorfield
<Fake sig link removed>
__________________
It's all happening for a reason.
Last edited by honorfield; 07-26-2009 at 08:11 PM..
Reason: Fake sig link removed
|