Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Refresh a page using JavaScript or HTML [duplicate]

People also ask

How do you refresh a page using JavaScript?

In JavaScript, you refresh the page using document. location. reload() . You can add the true keyword to force the reloaded page to come from the server (instead of cache).

How do you refresh the same page in HTML?

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

How do you automatically refresh a page in HTML?

Approach 1: One can auto refresh the webpage using the meta tag within the head element of your HTML using the http-equiv property. It is an inbuilt property with HTML 5. One can further add the time period of the refresh using the content attribute within the Meta tag.

Which method is used to refresh the webpage in JavaScript?

JavaScript reload() method In JavaScript, the reload() method is used to reload a webpage. It is similar to the refresh button of the browser.


window.location.reload(); in JavaScript

<meta http-equiv="refresh" content="1"> in HTML (where 1 = 1 second).


Here are 535 ways to reload a page using javascript, very cool:

Here are the first 20:

location = location
location = location.href
location = window.location
location = self.location
location = window.location.href
location = self.location.href
location = location['href']
location = window['location']
location = window['location'].href
location = window['location']['href']
location = window.location['href']
location = self['location']
location = self['location'].href
location = self['location']['href']
location = self.location['href']
location.assign(location)
location.replace(location)
window.location.assign(location)
window.location.replace(location)
self.location.assign(location)

and the last 10:

self['location']['replace'](self.location['href'])
location.reload()
location['reload']()
window.location.reload()
window['location'].reload()
window.location['reload']()
window['location']['reload']()
self.location.reload()
self['location'].reload()
self.location['reload']()
self['location']['reload']()

Original Article


simply use..

location.reload(true/false);

If false, the page will be reloaded from cache, else from the server.


window.location.reload()

should work however there are many different options like:

window.location.href=window.location.href

You can also use

<input type="button" value = "Refresh" onclick="history.go(0)" />

It works fine for me.