diff options
-rw-r--r-- | web/cobrands/fixmystreet/fixmystreet.js | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/web/cobrands/fixmystreet/fixmystreet.js b/web/cobrands/fixmystreet/fixmystreet.js index bafe88635..d98730b62 100644 --- a/web/cobrands/fixmystreet/fixmystreet.js +++ b/web/cobrands/fixmystreet/fixmystreet.js @@ -759,7 +759,7 @@ $.extend(fixmystreet.set_up, { // we want to record the navigation as a state, so the user // can return to it later using their Back button. if ('pushState' in history) { - history.pushState(null, null, reportListUrl); + history.pushState({ initial: true }, null, reportListUrl); } }); }); @@ -1050,6 +1050,11 @@ $(function() { setup_func(); }); + // Have a fake history entry so we can cover all eventualities. + if ('replaceState' in history) { + history.replaceState({ initial: true }, null); + } + $(window).on('load', function () { setTimeout(function () { window.addEventListener('popstate', function(e) { @@ -1060,9 +1065,16 @@ $(function() { // because we're already inside a popstate: We want to roll // back to a previous state, not create a new one! + if (!fixmystreet.page) { + // Only care about map pages, which set this variable + return; + } + var location = window.history.location || window.location; if (e.state === null) { + // Hashchange or whatever, we don't care. + } else if ('initial' in e.state) { // User has navigated Back from a pushStated state, presumably to // see the list of all reports (which was shown on pageload). By // this point, the browser has *already* updated the URL bar so |