1 reply [Last post]
blah45
Offline
newbie
Last seen: 17 years 21 weeks ago
Joined: 2004-09-01
Posts: 1
Points: 0

I'm trying to get the background image of a table cell to change/rollover when you mouse over a link. This code works in IE, but in Firefox/Mozilla/Netscape it says that it can't find the object "changebg", so is there another way to pass the object's name?

I know this can be done by calling onmouseover/out from the TD tag but I have to get it working from a link (there will be multiple links each with a different rollover image in the TD).

The sample webpage:
http://www.cuberis.com/rollover/tdrollover2.html

Code:

<html> 
<head> 
<title>Change Test</title> 
<style type="text/css"> 
td.image { 
background: url(intside1.jpg); 
} 
td.image2 { 
background: url(intside2.jpg); 
} 
</style> 
</head> 

<body> 
<table width="100" height="100"> 
<tr> 
<td id="changebg" name="changebg">
<a href="#" onmouseover="changebg.className='image2'" onmouseout="changebg.className='image'">Change</a>
</td> 
</tr> 
</table> 
</body> 
</html>

Thanks!

loudsox04
Offline
Regular
Boston, MA
Last seen: 17 years 29 weeks ago
Boston, MA
Timezone: GMT-4
Joined: 2004-07-06
Posts: 33
Points: 0

cell background rollover can't find object?

I don't know why that didn't work, but I always use this.className='whatever' instead of refering to an element's id. This seems to work on Netscape, Mozilla, etc. Good luck! - Jen