Javascript Reference - Location reload() Method








The reload() method can reload the current document.

It does the same as the reload button in your browser.

By default, the reload() method reloads from page the cache, but we can force to get the page from server by pass-in true parameter: location.reload(true).

Browser Support

reload Yes Yes Yes Yes Yes

Syntax

location.reload(forceGet)




Parameter Values

Parameter Type Description
forceGet Boolean Optional.
  • false - Default. Reloads the current page from the cache.
  • true - Reload from the server

Return Value

No return value

Example

The following code shows how to reload the current document.


<!DOCTYPE html>
<html>
<body>
<!--  ww w .  j  a  v a2s.  c o  m-->
<button onclick="myFunction()">Reload page</button>

<script>
function myFunction() {
    location.reload();
}
</script>

</body>
</html> 

The code above is rendered as follows: