Skip to content

Instantly share code, notes, and snippets.

@seemikehack
Created May 5, 2015 04:22
Show Gist options
  • Save seemikehack/8bee2dfa0033f7006b3c to your computer and use it in GitHub Desktop.
Save seemikehack/8bee2dfa0033f7006b3c to your computer and use it in GitHub Desktop.
Absolutely, positively squash an event in the most cross-browser-compatible way imaginable (thanks, IE8).
// see http://www.quirksmode.org/js/events_order.html for a fun read
// if you're wondering why all the type-coercion b.s., why not, since this function has to exist in the first place
function killEvent(e) {
e = e || window.event;
e.cancelBubble = true;
e.returnValue = !true;
return !!(e.stopPropagation && (e.stopPropagation() || e.preventDefault()));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment