I have some massively nested GUI controls - when they're clicked or changed or whatever I need to stop the event from going further up the DOM tree. It needs to work across all browsers.
At this point I've got some rather clunky JS code:
//Do something in response to the original user action
//Leave it at that.
try {
e.stopPropagation();
}
catch (ex) {
}
try {
event.cancelBubble();
}
catch (ex) {
}
try {
event.preventDefault();
}
catch (ex) { }
...
This does work, but it smells and feels wrong (personally I loathe empty catch blocks). Is there a neater x-browser trick I can use?