venantius / accountant

ClojureScript navigation for single-page applications, made simple.
Eclipse Public License 1.0
250 stars 39 forks source link

Bypassing history #56

Closed BorisKourt closed 6 years ago

BorisKourt commented 6 years ago

Hi,

I ended up using accountant for a slightly different purpose. I trigger a transition animation on any link click, and once it completes I actually load that page using a call to location.replace

Accountant has been super helpful by being able to capture all the links on the page.

Unfortunately once the next page loads, the back button is broken. The browser never returns to the original page.

Is there a way to disable just the history functionality of accountant?

venantius commented 6 years ago

If you want the back button to work, disabling the history functionality of accountant will not fix your problem. location.replace does not work with the back button. From the relevant MDN docs:

The Location.replace() method replaces the current resource with the one at the provided URL. The difference from the assign() method is that after using replace() the current page will not be saved in session History, meaning the user won't be able to use the back button to navigate to it.

If you want to keep things working, why not just set window.location = $YOUR_URL?

BorisKourt commented 6 years ago

Ah that is entirely my bad! Copied it from my prior code where I didn't want the user to go back. ('permanent redirect')

Sorry about that, closing.