Jump to content

"onmouseover" not working


Corbeau

Recommended Posts

Hello. I have a table with a cell that says:

---

<td id="hex" rowspan=2 height='66' background='hex.gif' onmouseover="hex-active()" onmouseout="hex-normal()"></td>---

Also, predifined functions within main document <head> tags:

----

<head><script>function hex-active(){document.getElementById("hex").innerHTML="<img src=hex-active.gif>";}function hex-normal(){document.getElementById("hex").innerHTML="";}</script></head>

----

 

According to everything I know, it should be working. But it isn't. Completely dead. Anyone got any idea what could be wrong? Thanks.

Link to comment
Share on other sites

You can't put dashes in function names. A dash isn't a legal character.

 

Actually you should just use :hover in CSS for this. The result will simpler and less mouse-erratic.

<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><title>Title</title><style>td{height: 66px;width: 66px;background-image: url('hex.gif');}td:hover{background-image: url('hex-active.gif');}</style><script>window.onload = init;function init(){document.getElementById('hex1').onmouseover = hex_active;document.getElementById('hex1').onmouseout = hex_normal;}function hex_active(){/*document.getElementById("hex1").innerHTML = '<img src="hex-active.gif">';*/}function hex_normal(){/*document.getElementById("hex1").innerHTML = "";*/}</script></head><body><table><tr><td id="hex1" rowspan="2">1</td><td>2</td></tr><tr><td>3</td></tr></table></body></html>
Edited by davej
Link to comment
Share on other sites

 

You can't put dashes in function names. A dash isn't a legal character.

 

/me slaps himself around a bit with a large trout

 

Thank you.

 

/me bangs his head against the wall a few times

 

Yeah, feeling better.

 

Much, much better.

Edited by Corbeau
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...