Javascript Location Reload

Reload/refresh a page with javascript

To reload or refresh the current page with javascript, you can use the reload() function.

To make a link that refreshes the current page you can use the code below:

<a href="#" onclick="location.reload(true)">refresh</a>

This link will appear like this:


I recommend that you include the current page URL within the href="" section, to ensure that users with javascript disabled or unavailable have a chance too!

Alternative technique

I found at some point in the past that this didn't always work, so instead you can ask the browser to load the current page. This method is not recommended, however, as it should show you a local cache of the page.

<a href="#" onclick="history.go(0)">refresh</a>

This link will appear as below:




As you said in your post, the

As you said in your post, the 'alternative method' doesn't reload the page at all unless the visitor doesn't have a cache, so I don't recommend anyone actually use it.

>>history.go(-1) to simulate

>>history.go(-1) to simulate the back button.

Yeh, this is typically what the history object is for, although I have seen some inconsistencies cross-browser.


This is the same as location.reload(), I believe, which I think is supposed to reload from the browser cache.

Location.reload(true) should force a reload from the server.

Add new comment