clock  Mon - Sun 8.00 AM - 8.00 PM
mail  edu@teknowize.com
fb
instagram
play store
pinterest

How To Refresh Web Page Using javaScript

  Sumit Dey Sarkar
  31 Aug 2022
  JavaScript
Imperial Advance Hero Image

How To Refresh Web Page Using javaScript

In this tutorial we will learn how to refresh web page using javaScript.

We can use this when we need to refresh web page after every 5 second , 10second , 15 second , 20second , 25 second , 30 second etc.

Here we will see two examples -

1) using setTimeout

2) Using setInterval

let's see examples one by one

1) How to refresh web page using javaScript setTimeout

<!DOCTYPE html>
<html>
<head>
	<title>How to refresh web page after 10 second using javaScript setTimeout</title>
</head>
<body>

<h2>How to refresh web page after 10 second using javaScript setTimeout</h2>

<script type="text/javascript">
   setTimeout(function(){
       location.reload();
   },10000);
</script>

</body>
</html>

 

2) How to refresh web page using javaScript setInterval

<!DOCTYPE html>
<html>
<head>
	<title>How to refresh web page after 10 second using javaScript setInterval</title>
</head>
<body>

<h2>How to refresh web page after 10 second using javaScript setInterval</h2>

<script type="text/javascript">
function refreshWebPage()
    {
        window.location = window.location.href;
    }
    setInterval('refreshWebPage()', 10000);
</script>

</body>
</html>