Is there a way to run a function only if event.preventDefault () is called in an event (another unknown function). This is for the jQuery plugin, so I don't know what other parts of the page can do. I tried this:
Event.test = Event.preventDefault; Event.preventDefault = function () { alert('Success'); this.test(); }
but it doesnβt work ... it just behaves as usual, without errors.
And vice versa, I also want the opposite ... to call the function only if event.preventDefault () is not called. Essentially, add a function to the default action for the event. Any ideas? Is all this possible?
Edit: based on the comment, I have a solution to the first problem: http://jsfiddle.net/nathan/VAePB/9/ . It works in Chrome ( function preventDefault() { [native code] } notifications, but IE warns undefined ). Therefore, IE will not allow me to define Event.prototype.test, but it will allow me to override Event.prototype.preventDefault. might come up with a solution to a second problem based on this if I can just get it to work in IE.
source share