...

View Full Version : Simple Rollover Button Problem - Newbie



wobblehead
12-22-2004, 02:14 PM
Hi,

I'm new to Javascript, and I would be so grateful if anyone could help me out here. I'm trying to create a rollover button as part of a navigation bar I am going to create in due course. I just can't get the rollover to work though. The actual button appears, however when you hover the mouse over it, nothing happens. Thank you for taking time to help me, and a merry christmas & a happy new year to everybody!




<?xml version="1.0" encoding = "UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title> Big Dog Music News - Homepage </title>
<link rel="stylesheet" type="text/css" href="home.css"/>
<script language="Javascript" type="text/javascript">

<!-- Hide script from old browsers

if(document.images)
{
buttonLightPurple = new Image
buttonDarkPurple = new Image

buttonLightPurple.src = "images/homeButton.gif"
buttonDarkPurple.src = "images/homeButtonRollover.gif"
}

else
{
buttonLightPurple = ""
buttonDarkPurple = ""
document.button = ""
}

// End hiding script from old browsers

</script>
</head>

<body>

<div id="header" align="center">
<table width=75%>
<tr>
<td class="dollar">
<img src="images/dollar.gif" alt="dollar"/>
</td>
<td id="logo">
<img src="images/heading.gif" alt="logo"/>
</td>
<td class="dollar">
<img src="images/dollar.gif" alt="dollar"/>
</td>
</tr>
</table>
</div>

<a href="index.html"
onmouseover="document.button.src=buttonDarkPurple.src"
onmouseout="document.button.src=buttonLightPurple.src"
<img src="images/homeButton.gif" border="0" name="button" alt="button"/>
</a>

</body>

</html>



Thanks again!

Joe P aka Wobblehead

:)

Willy Duitt
12-22-2004, 04:00 PM
For one you never closed your opening anchor tag and by not working I assume that you can not even see the image...

<a href="index.html"
onmouseover="document.button.src=buttonDarkPurple.src"
onmouseout="document.button.src=buttonLightPurple.src">

.....Willy

Willy Duitt
12-22-2004, 04:57 PM
You can also look here:
http://www.webdeveloper.com/forum/showthread.php?s=&postid=291766#post291766

.....Willy



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum