How to refresh a page using a hash?

I am updating the pages, writing window.location = window.location; . However, this does not work on the page, for example / page # c22. He will simply jump to any point of c22. How to refresh the page?

There is no need to use the switch to # c22 after the update, but I'm sure there is a more reliable way than window.location = window.location .

+4
source share
4 answers

You may try:

 window.location.reload(true); 

reload(forceget) : reload the document from the current URL. forceget is a boolean that, when true , forces the page to always reload from the server. If it is false or not specified, the browser can reload the page from its cache. ( Source )

+7
source

You can use this:

 window.location.reload(); 

The specification for this is here at W3C

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

+3
source

Try:

 location.reload(true) 
+3
source

" Automatically reloading the page with parameters " is an attempt to save get parameters.

Perhaps you wanted to use location.pathname .

+1
source

Source: https://habr.com/ru/post/1306555/


All Articles