Closed Bug 163435 Opened 22 years ago Closed 22 years ago

event handling in script vs. tag, different behaviour

Categories

(Core :: DOM: Events, defect)

x86
Windows 2000
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 179974

People

(Reporter: matthijs.wensveen, Assigned: joki)

References

()

Details

Attachments

(1 file)

An event handler assigned with DOM methods or otherwise via a script has different behaviour than an event handler assigned in a tag. Specifically, the event handler in the textarea tag for onkeypress receives the event before the character is inserted and can be cancelled in time, whereas the script-wise assigned handlers cannot prevent the character to be inserted. example: <html> <head> <title> New Document </title> <script> function initEventListeners() { document.testForm.textArea2.onkeypress = limitC; document.testForm.textArea3.addEventListener("keypress", limitC, false); } function limitC() { return false; } </script> </head> <body onload="initEventListeners()"> <form name="testForm" action="testForm.html" method="GET"> <textarea id="textArea1" cols="40" rows="5" wrap="soft" onkeypress="return limitC();"></textarea><br> <textarea id="textArea2" cols="40" rows="5" wrap="soft"></textarea><br> <textarea id="textArea3" cols="40" rows="5" wrap="soft"></textarea><br> </form> </body> </html>
Whiteboard: DUPEME
Attached file testcase (deleted) —
In the second text area if you press tab the focus is not changed, but in the third text area it is working...
Status: UNCONFIRMED → NEW
Ever confirmed: true
*** This bug has been marked as a duplicate of 179974 ***
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → DUPLICATE
Whiteboard: DUPEME
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: