- From: Amy Lee <amy@avantgo.com>
- Date: Tue, 28 Jan 2003 14:23:24 -0800
- To: <www-dom@w3.org>
- Message-ID: <4C4CB317C3CD6A40AAF9B1C7686696690312925F@kali.avantgo.com>
My script is as follows. Can I use the event type of addEventHandler as onEventHandlers like Q1 and Q2 instead of using "click" or "focus"? This script doesn't work under Netscape but if I change it to "click" or "focus", that will work. I am just wondering which way is right since the spec is not clear to me. I would appreciate if anybody can answer especially any W3 members. Thanks! <html> <head> <title>DOM addEventListener </title> <script> // Event Registration Example function l_func() { button = document.getElementById("mybutton"); button.value = "clicked"; } function load() { button = document.getElementById("mybutton"); button.addEventListener("onclick", l_func, false); ----------------------------------->Q1 button.click(); if(button.value == "clicked") { body = document.getElementById("mybody"); text = document.createTextNode("PASSED"); body.appendChild(text); } else { body = document.getElementById("mybody"); text = document.createTextNode("FAILED"); body.appendChild(text); } } function l_func2() { text = document.getElementById("mytext"); text.value = "hi"; } function load2() { text = document.getElementById("mytext"); text.addEventListener("onfocus", l_func2, false); ------------------------------Q2 text.focus(); } </script> </head> <body id="mybody" onload="load();load2();" > <input type="button" value="Button" id="mybutton"> <input type="text" value="Text" id="mytext"><br> <b>Try this on Netscape. This doesn't work under IE.</b> <hr>Test status: </body> </html>
Received on Tuesday, 28 January 2003 17:23:36 UTC