reload page javascript

Reload Page Using Javascript

Reload Page Javascript We can easily Reload the whole web page using JS method “location.reload()”. This method works the same as the browser reload the page.

By default, the location.reload() method reloads the page from the browser cache, but you can force it to reload the page from the server by setting the Boolean value parameter to true.
Example : location.reload(true);

Reload Page Syntax in JS

location.reload(Boolean value);

In the above syntax, boolean value is optional parameter.

true : Reload the current web page from the Server.

false (By Default): Reload the current web page from the browser cache.

Example : In the follwoing example, we will reload the whole page by using javascript onclick event.

Refresh Page on Button Click HTML

<!DOCTYPE html>
<html>
<head>
<title>Deveoper Helps</title>
</head>
<body>
<input type="button" value="RELOAD PAGE" onclick="reloadPage()"/>
<script>

function reloadPage(){
location.reload();
}

</script>
</body>
</html>

Output :

Page will be reload after clicking Button. 

Javascript Refresh page every minute

<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body onload="reloadPage();">
<h2>RELOAD PAGE EVERY MINUTE USING JAVASCRIPT</h2>
<script>

function reloadPage(){
setTimeout("location.reload();",60000); //1000 miliseconds means 1 second
}

</script>
</body>
</html>

Output :

Page will reload every minute.

Thanks for the reading post. I hope you like and understand the post. If you have any doubt regarding this post please comment below.

More Related Post

Leave a comment

Your email address will not be published. Required fields are marked *

0 0 0
FOLLOW ON