Add EventListener to <a href...> tag
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

Add EventListener to <a href...> tag

From: Fabio Cavassini <cavassinif@gmail.com>
Date: Thu Dec 15 2005 - 22:06:16 CET

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
Received on Fri Dec 23 20:22:59 2005