Skip to content

Instantly share code, notes, and snippets.

@bhaireshm
Last active June 22, 2021 13:04
Show Gist options
  • Save bhaireshm/7431854563a72b56ed15436ee8fad4f9 to your computer and use it in GitHub Desktop.
Save bhaireshm/7431854563a72b56ed15436ee8fad4f9 to your computer and use it in GitHub Desktop.
Disable browser back button using JavaScript.
function blockBrowserBackButton() {
history.pushState(null, null, location.href);
window.onpopstate = function () {
history.go(1);
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment