Closed
Bug 132777
Opened 23 years ago
Closed 21 years ago
Exception in event handler does not cancel the event (should it?)
Categories
(Core :: DOM: Events, defect, P5)
Core
DOM: Events
Tracking
()
RESOLVED
WONTFIX
People
(Reporter: vytis, Assigned: joki)
References
Details
Try this:
<a href="http://www.lrytas.lt" onclick="alert();return false;">aaaaa</a>
It is working.
Try this:
<a href="http://www.lrytas.lt" onclick="alert();return false;">aaaaa</a>
It doesn't work.
Updated•23 years ago
|
Summary: "return false" doesn't work on onClick of tag <a>, if onClick calls two functions → "return false" doesn't work on onClick of tag <a>, if onClick calls two functions
Comment 1•23 years ago
|
||
Any difference I'm missing between the two cases.
It should be:
Try this, one function:
<a href="http://www.lrytas.lt" onclick="return false;">aaaaa</a>
It is working.
Try this, two functions:
<a href="http://www.lrytas.lt" onclick="alert();return false;">aaaaa</a>
It doesn't work.
Comment 3•23 years ago
|
||
That is incorrect Javascript.
You have no string as an argument to the alert.
![]() |
||
Comment 4•23 years ago
|
||
Yep. That's the problem... the alert() with no arguments throws an exception
and so the return false is never executed. Over to events to decide whether an
exception in an event handler should affect event propagation in any way.
Assignee: rogerl → joki
Status: UNCONFIRMED → NEW
Component: JavaScript Engine → DOM Events
Ever confirmed: true
OS: Windows 2000 → All
QA Contact: pschwartau → vladimire
Hardware: PC → All
Summary: "return false" doesn't work on onClick of tag <a>, if onClick calls two functions → Exception in event handler does not cancel the event (should it?)
Comment 5•22 years ago
|
||
If it should this is low priority because its up to the web developer to make
sure that there is NO exceptions when execting an event handler.
Priority: -- → P5
![]() |
||
Comment 6•21 years ago
|
||
jst, should exceptions in an event handler cancel the event? My instinct is "no".
Comment 7•21 years ago
|
||
I'd say no too. If you want to cancel an event, don't throw exceptions, catch
them and do the right thing in stead.
Status: NEW → RESOLVED
Closed: 21 years ago
Resolution: --- → WONTFIX
You need to log in
before you can comment on or make changes to this bug.
Description
•