+ // Set a non-null initial state, so that the e.originalEvent.state
+ // check below works correctly when going back to the initial page.
+ window.history.replaceState({}, document.title, window.location);
+
+ $(window).on('popstate', function(e) {
+ if (!e.originalEvent.state) return; // Is it a real popstate event or just a hash change?