Preferred method to reload page with JavaScript? [closed]

Preferred method to reload page with JavaScript? [closed]

which way to reload a current page (using a button) would you prefer?
1
2
3
4
5
6

As the URL of the page changes frequently AFAIK a ‘fallback function’ like
Reload

won’t work for me, right?

Solutions/Answers:

Solution 1:

Depends on what you want to do. The fourth and sixth methods there won’t reload any form data, they essentially make a separate visit to the page. Some versions of Firefox also have issues with the third method. Other than that, I’d go with the fifth as a personal preference. It seems the clearest.

Solution 2:

You may also do:

wd represents window || document:

  • wd.location.assign(wd.location.href) :
    go to the URL
  • wd.location.replace(wd.location.href) :
    go to the URL and replace previous page in history
  • wd.location.reload(<true/false/blank>) : reload page from server/cache/cache