1window.history.pushState({page: 1}, "", "");
2
3window.onpopstate = function(event) {
4
5 // "event" object seems to contain value only when the back button is clicked
6 // and if the pop state event fires due to clicks on a button
7 // or a link it comes up as "undefined"
8
9 if(event){
10 // Code to handle back button or prevent from navigation
11 }
12 else{
13 // Continue user action through link or button
14 }
15}
16
1function goBack() {
2 window.location.hash = window.location.lasthash[window.location.lasthash.length-1];
3 window.location.lasthash.pop();
4}