0

I'm testing window.location.reload() to see if I can use it to ensure that a client dashboard has the latest value if the client arrives at the dashboard from a forward or back button click.

Unfortunately the default behavior of this method in Chrome and possibly other browsers causes the browser to reload a seemingly endless number of times.

Is there a way to force window.location.reload() to reload the current URL only one time?

If I can get that to work maybe I can use window.history or some other method to determine if the client arrived at the page from a forward or back button click. Still researching that.

1
  • 1
    Put a flag in local storage Commented Jan 29, 2021 at 20:00

1 Answer 1

2

One approach would be to set a sessionStorage Variable.

if(sessionStorage.getItem('loaded') === null) { sessionStorage.setItem('loaded', true); window.location.reload(); } 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.