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)

defect

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.
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
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.
That is incorrect Javascript. You have no string as an argument to the alert.
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?)
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
jst, should exceptions in an event handler cancel the event? My instinct is "no".
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
Blocks: 233142
You need to log in before you can comment on or make changes to this bug.