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)
.
reload |
Yes | Yes | Yes | Yes | Yes |
location.reload(forceGet)
Parameter | Type | Description |
---|---|---|
forceGet | Boolean | Optional.
|
No return value
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: