Canceling events
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

Canceling events

From: alex <alexis.roda.villalonga@gmail.com>
Date: Sun Apr 09 2006 - 22:33:02 CEST

Hi,
I have code that looks like this:

function setupEventWrapper(obj) {
     old_ev_handler = obj.onsubmit;
     obj.onsubmit = function () {
         do_something();
         if (old_ev_handler != undefined) {
             old_ev_handler();
         }
         if (event_cancelled()) {
             undo_something();
         }
     }
}

it wraps the onsubmit handler (if any) within a new function which
do_something() and then calls the old event handler.

My problem is how can I detect if the event has been canceled by
old_ev_handler(). AFAIK an event can be cancelled in three ways:

* returning false, easy to check for

* setting event.returnValue = false on IE, easy to check for

* calling event.preventDefault() on DOM

How can I check if event.preventDefault() has been called?

Thanks in advance
Received on Mon May 1 04:52:13 2006