Corbeau Posted September 25, 2013 Share Posted September 25, 2013 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 More sharing options...
davej Posted September 25, 2013 Share Posted September 25, 2013 (edited) 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 September 25, 2013 by davej Link to comment Share on other sites More sharing options...
Corbeau Posted September 25, 2013 Author Share Posted September 25, 2013 (edited) 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 September 25, 2013 by Corbeau Link to comment Share on other sites More sharing options...
thescientist Posted September 25, 2013 Share Posted September 25, 2013 always check the browsers console. syntax errors are one of the things that would show up there. Link to comment Share on other sites More sharing options...
Corbeau Posted September 26, 2013 Author Share Posted September 26, 2013 <style>td{height: 66px;width: 66px;background-image: url('hex.gif');}td:hover{background-image: url('hex-active.gif');}</style> Actually, on a closer look, if I do it like this, I don't even need the JavaScript? At least not for this? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now