Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dogrocker/5ea042a04c419867a757 to your computer and use it in GitHub Desktop.
Save dogrocker/5ea042a04c419867a757 to your computer and use it in GitHub Desktop.
Prevent BACKSPACE from navigating back with jQuery (Like Google's Homepage)
$(document).on("keydown", function (e) {
    if (e.which === 8 && !$(e.target).is("input:not([readonly]):not([type=radio]):not([type=checkbox]), textarea, [contentEditable], [contentEditable=true]")) {
        e.preventDefault();
    }
});

Ref: http://stackoverflow.com/a/13756505/2126472

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment