Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript Reload Page

Tags:

javascript

In order to reload the page without fully reloading everything I'm using:

window.top.location=window.top.location; 

However, this doesn't work for some reason when there is anchor text. It appears to do nothing in this case, but more likely it refreshes the anchor.

Any fix for this that will reload the page (as above) without reloading the cached images and scripts?

like image 960
Alasdair Avatar asked Apr 27 '13 03:04

Alasdair


People also ask

How do I reload a page in JavaScript?

You can use the location. reload() JavaScript method to reload the current URL. This method functions similarly to the browser's Refresh button. The reload() method is the main method responsible for page reloading.

How do you refresh a HTML page?

The reload() method reloads the current document. The reload() method does the same as the reload button in your browser.

What is reload in JavaScript?

In JavaScript, the reload() method is used to reload a webpage. It is similar to the refresh button of the browser. This method does not return any value.

What is location reload in JavaScript?

The location reload() method in HTML DOM is used to reload the current document. This method refreshes the current documents. It is similar to the refresh button in the browser. Syntax: location.reload( forceGet ) Parameters: This method contains single parameter forceGet which is optional.


1 Answers

Try using location.reload(false).

As MDN says, the second parameter is a boolean indicating whether to bypass the cache or not. false keeps using the cache, as you wanted.

like image 83
icktoofay Avatar answered Sep 19 '22 13:09

icktoofay