Closed
Bug 163435
Opened 22 years ago
Closed 22 years ago
event handling in script vs. tag, different behaviour
Categories
(Core :: DOM: Events, defect)
Tracking
()
RESOLVED
DUPLICATE
of bug 179974
People
(Reporter: matthijs.wensveen, Assigned: joki)
References
()
Details
Attachments
(1 file)
(deleted),
text/html
|
Details |
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>
Updated•22 years ago
|
Whiteboard: DUPEME
Comment 1•22 years ago
|
||
Comment 2•22 years ago
|
||
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
Comment 3•22 years ago
|
||
*** This bug has been marked as a duplicate of 179974 ***
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → DUPLICATE
You need to log in
before you can comment on or make changes to this bug.
Description
•