Skip to content

Instantly share code, notes, and snippets.

@kdarty
Last active September 15, 2016 16:03
Show Gist options
  • Save kdarty/632396b5c910c131d80833fb4ec47e76 to your computer and use it in GitHub Desktop.
Save kdarty/632396b5c910c131d80833fb4ec47e76 to your computer and use it in GitHub Desktop.
Prevent Users from using the BACK Button. To do this we must actually put a tiny piece of JavaScript on the Page we do not want users to go back to. In other words, once they leave the page, if they attempt to return they will be forced back to the page they left.
/* [Begin] Prevent User from Returning to this Page after Submit */
function disableBack() {
window.history.forward()
}
window.onload = disableBack();
window.onpageshow = function (event) { if (event.persisted) disableBack() }
/* [End] Prevent User from Returning to this Page after Submit */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment