Skip to content

Instantly share code, notes, and snippets.

@pushpinderbagga
Last active April 29, 2016 04:09
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 pushpinderbagga/2d2f2ac90ab03b998828d8b1f64dbeaf to your computer and use it in GitHub Desktop.
Save pushpinderbagga/2d2f2ac90ab03b998828d8b1f64dbeaf to your computer and use it in GitHub Desktop.
Detect Browser Back Button using Javascript
window.onload = function () {
if (typeof history.pushState === "function") {
history.pushState("state", null, null);
window.onpopstate = function () {
history.pushState('newstate', null, null);
//Browser Back Button Pressed - Put your logic here onwards.
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment