Closed
Bug 107689
Opened 24 years ago
Closed 24 years ago
preventDefault() don't work
Categories
(Core :: DOM: Events, defect)
Tracking
()
People
(Reporter: svujic, Assigned: joki)
References
()
Details
Attachments
(1 file)
|
980 bytes,
text/html
|
Details |
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:0.9.5)
BuildID: 2001101117
PreventDefault() can't suppress display of chars in INPUT element.
That happens only in case when keypress event handler is attached to INPUT
element dynamicly.
Test case code below:
All commneted lines reproduce same result.
<html>
<head>
<script language="javaScript">
lOnce=true
function of(evt){
if(lOnce)
//evt.target.onkeypress=okp
//evt.target.onkeypress=Function("okp(arguments[0])")
//evt.target.onkeypress=function(event){ okp(arguments[0]) }
//evt.target.addEventListener("keypress",function(event){ okp
(arguments[0]) },true)
//evt.target.addEventListener("keypress",new Function
("event","okp(event)"),true)
//evt.target.addEventListener("keypress",new Function("okp
(arguments[0])"),true)
evt.target.addEventListener("keypress",okp,true)
lOnce=false
}
function okp(evt){
window.status+=((evt.keyCode==0)? evt.charCode : evt.keyCode)+"-"
evt.preventDefault()
}
</script>
</head>
<body>
<input id="i1" type="text" value="111.99"
onkeypress="okp(event)" />
<font color="navy">HTML event binding</font>
<br>
<input id="i2" type="text" value="111.99"
onfocus="of(event)" />
<font color="navy">JS event binding</font>
</body>
</html>
Reproducible: Always
Steps to Reproduce:
1.Just try to load test case above
2.
3.
Actual Results: Displaying of pressed keys
Expected Results: Opposite of actual result
Comment 1•24 years ago
|
||
Comment 2•24 years ago
|
||
Confirming, just open the attachment and try to type in first and second fields.
They both use the same handler, except the second case attaches it dynamicly...
In case one handler is called first
In case two the letter is displayed and only then the event handler is called!
Status: UNCONFIRMED → NEW
Ever confirmed: true
| Assignee | ||
Comment 3•24 years ago
|
||
*** This bug has been marked as a duplicate of 54035 ***
Status: NEW → RESOLVED
Closed: 24 years ago
Resolution: --- → DUPLICATE
You need to log in
before you can comment on or make changes to this bug.
Description
•