You can simply use the JavaScript location.reload() method to refresh or reloads the page. This method optionally accepts a Boolean parameter true or false.
If the parameter true is specified, it causes the page to always be reloaded from the server. But, if it is false (which is default) or not specified, the browser may reload the page from its cache.
Let's check out an example to understand how this method basically works:
You can also do the same thing with plain JavaScript. You don't need jQuery for this. Check out the following example which is the modified version of the previous example.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Refresh the Page with JavaScript</title>
<script>
function reloadPage(){
location.reload(true);
}
</script>
</head>
<body>
<button type="button" onclick="reloadPage();">Reload page</button>
</body>
</html>
Use the JavaScript
location.reload()MethodYou can simply use the JavaScript
location.reload()method to refresh or reloads the page. This method optionally accepts a Boolean parametertrueorfalse.If the parameter
trueis specified, it causes the page to always be reloaded from the server. But, if it isfalse(which is default) or not specified, the browser may reload the page from its cache.Let's check out an example to understand how this method basically works:
You can also do the same thing with plain JavaScript. You don't need jQuery for this. Check out the following example which is the modified version of the previous example.
need an explanation for this answer? contact us directly to get an explanation for this answer