Created
September 30, 2014 11:56
-
-
Save getify/a523250a779d12993d99 to your computer and use it in GitHub Desktop.
hijacking clicks using "capturing phase" event handler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// hijack the next click anywhere | |
if (document.addEventListener) { | |
document.addEventListener("click",function handler(evt){ | |
evt.preventDefault(); | |
evt.stopPropagation(); | |
evt.stopImmediatePropagation(); | |
document.removeEventListener("click",handler,true); | |
// now do whatever else in response to the hijacked click | |
},/*capturing=*/true); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment