views:

57

answers:

4

I refresh pages by writing window.location = window.location;. However this doesn't work on a page like /page#c22. It will just jump to whereever c22 is. How do I refresh the page?

It does not need to use go to #c22 once refreshed but I am sure there is a more dependable way than window.location = window.location.

+2  A: 

You can use this:

window.location.reload();

The spec for this is here, at the W3C

This function forces the host application to reload the resource identified by the Location.

Nick Craver
+2  A: 

You may want to try:

window.location.reload(true);

reload(forceget): Reload the document from the current URL. forceget is a boolean, which, when it is true, causes the page to always be reloaded from the server. If it is false or not specified, the browser may reload the page from its cache. (Source)

Daniel Vassallo
A: 

"Page auto reload with parameters" is one tried to preserve get parameters.

Probably you wanted to use location.pathname.

jonny
+1  A: 

Try:

location.reload(true)
nik