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.

Very true - this article is

Very true - this article is actually a few years old, and for some reason the second method worked for me then. But that was probably me not understanding caching at the time!

I use history.go(-1) to

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

Does location.reload(false) do anything special?

>>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.

I am using in the code behind

I am using in the code behind:
string script = " location.reload(true); ";
this.Clientscript.RegisterStartupscript(script.GetType(), "referesh", script);
And I've got a strenge message from internet explorer which ask me to click Retry or Cancel and it loop if I press Retry (Cancel do nothing, but the PopUp Message stay there).
Any ideea?


I didn't know there is reload(boolean)...

Add new comment