This is driving me crazy - I'm following through some basic rollover code
(below with all extra content stuff stripped away. When I mouseover the
image, IE errors, reporting "imagesHili te is undefined". Why?
I've used the rem'ed out alert to prove the preLoad code runs and the mouse
events pass the expected 'type' argument. Anyone show what I'm doing wrong?
######### code starts #########
<html><head><ti tle>Image Swap Test</title>
<script language="JavaS cript" type="text/JavaScript">
function preloadImages() {
if (document.image s) {
var imagesNormal = new Object();
imagesNormal["home"] = new Image(130, 20);
imagesNormal["home"].src = 'images/homenav1.gif';
var imagesHilite = new Object();
imagesHilite["home"] = new Image(130, 20);
imagesHilite["home"].src = 'images/homenav2.gif';
//alert(imagesNor mal["home"].src + ' | ' +
imagesHilite["home"].src);
}
}
function setImage(type) {
if (document.image s) {
if (type == 'hilite') {
document.images['home'].src = imagesHilite['home'].src;
//alert('hilite') ;
return true;
} else if (type == 'normal') {
document.images['home'].src = imagesNormal['home'].src;
//alert('normal') ;
return true;
}
}
return false;
}
</script></head>
<body bgcolor="#FFFFF F" text="#000000" onLoad="preload Images();"
leftmargin="0" topmargin="0">
<a href="home.htm" onmouseover="re turn setImage('hilit e');"
onmouseout="ret urn setImage('norma l');"><img name="home" height="20"
width="130" border="0" src="images/homenav1.gif" alt="Home Page"></a>
</body>
</html>
#### code ends ###########
Thanks,
Mark
(below with all extra content stuff stripped away. When I mouseover the
image, IE errors, reporting "imagesHili te is undefined". Why?
I've used the rem'ed out alert to prove the preLoad code runs and the mouse
events pass the expected 'type' argument. Anyone show what I'm doing wrong?
######### code starts #########
<html><head><ti tle>Image Swap Test</title>
<script language="JavaS cript" type="text/JavaScript">
function preloadImages() {
if (document.image s) {
var imagesNormal = new Object();
imagesNormal["home"] = new Image(130, 20);
imagesNormal["home"].src = 'images/homenav1.gif';
var imagesHilite = new Object();
imagesHilite["home"] = new Image(130, 20);
imagesHilite["home"].src = 'images/homenav2.gif';
//alert(imagesNor mal["home"].src + ' | ' +
imagesHilite["home"].src);
}
}
function setImage(type) {
if (document.image s) {
if (type == 'hilite') {
document.images['home'].src = imagesHilite['home'].src;
//alert('hilite') ;
return true;
} else if (type == 'normal') {
document.images['home'].src = imagesNormal['home'].src;
//alert('normal') ;
return true;
}
}
return false;
}
</script></head>
<body bgcolor="#FFFFF F" text="#000000" onLoad="preload Images();"
leftmargin="0" topmargin="0">
<a href="home.htm" onmouseover="re turn setImage('hilit e');"
onmouseout="ret urn setImage('norma l');"><img name="home" height="20"
width="130" border="0" src="images/homenav1.gif" alt="Home Page"></a>
</body>
</html>
#### code ends ###########
Thanks,
Mark
Comment