View Full Version : Intercepting mouse clicks globally

10 Feb 2010, 6:01 PM
I need to find out if a click event occurs anywhere on a page and need to do this in one central place. Once a click is detected, I need to run a few checks and if those checks fail, I must 'disable' the event ie. behave as if no click was ever done. So, even if a link was clicked, it'd not invoke it's click handler.
I can trap the even on document.body but it's too late at that point - I can't really prevent the event's handler from getting called. Is there a way to trap the event very early on?
Hope this makes sense.


14 Feb 2010, 12:29 PM
you can 'capture' the event (downward DOM event cycle). You should be able to attach a click handler to the document.body element