F
Fabio Cavassini
I want to clean my html from JavaScript and attach all EventHanding
code as:
document.getElementById('to').addEventListener('onMouseout',delayhidemenu,false);
document.getElementById('s').addEventListener('onMouseout',delayhidemenu,false);
that way, I can work with a clean HTML page and a separate JavaScript
file.
But, I can't make it work with links, having:
<SCRIPT LANGUAGE="JavaScript">
window.onload=function(){
document.getElementById('h').addEventListener('onClick',say,false);
}
function say(){
alert("hello");
}
</SCRIPT>
<a id="h" href="#">hhh</a>
Produces the error: The object doesn't accept this property or method.
How can I add an event handler to a <a> tag?
Best Regards
Fabio Cavassini
code as:
document.getElementById('to').addEventListener('onMouseout',delayhidemenu,false);
document.getElementById('s').addEventListener('onMouseout',delayhidemenu,false);
that way, I can work with a clean HTML page and a separate JavaScript
file.
But, I can't make it work with links, having:
<SCRIPT LANGUAGE="JavaScript">
window.onload=function(){
document.getElementById('h').addEventListener('onClick',say,false);
}
function say(){
alert("hello");
}
</SCRIPT>
<a id="h" href="#">hhh</a>
Produces the error: The object doesn't accept this property or method.
How can I add an event handler to a <a> tag?
Best Regards
Fabio Cavassini