Javascript Auto Refresh Current Page with Regular Intervals

Share this Article
Reading Time: 3 minutes
212 Views

Inside this article we will see the concept i.e Javascript Auto Refresh Current Page with Regular Intervals Example Tutorial. Article contains the classified information about How to Auto Refresh Page Every 10 Seconds using Javascript.

If you are looking for a solution i.e Refresh a Web Page in JavaScript in regular intervals then this article will help you a lot for this. Tutorial is super easy to understand and implement it in your code as well.

Learn More –

Let’s get started.

Application Programming

Create a folder say page-reload in your localhost directory. Create a file index.html into it.

Auto page reload in a specific Time (Single time only)

<!doctype html>
  
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Javascript Auto Refresh Current Page with Regular Intervals</title>
  </head>
  <body>

    <h3>Automatically Refresh or Reload a Page using Javascript</h3>

    <script>

	   setTimeout(function(){

	       location.reload();

	   },3000); // 3000 milliseconds means 3 seconds.

   </script>

  </body>

</html>

Concept

Reload page itself in a specific time period.

setTimeout(function(){

   location.reload(); // Reload page itself

},3000); // 3000 milliseconds means 3 seconds.

Auto page reload in regular intervals (Regular reload)

Open index.html file and write this code for it.

<!doctype html>
  
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Javascript Auto Refresh Current Page with Regular Intervals</title>
  </head>
  <body>

    <h3>Automatically Refresh or Reload a Page using Javascript</h3>

    <script>

	   setInterval(function(){

	       location.reload();

	   },3000); // 3000 milliseconds means 3 seconds.

   </script>

  </body>

</html>

Concept

After every 3 seconds, page itself get reload every time.

setInterval(function(){
    
     location.reload();

},3000); // 3000 milliseconds means 3 seconds.

Application Testing

Open browser and type your application URL:

URL: http://localhost/page-reload/index.html

We hope this article helped you to learn Javascript Auto Refresh Current Page with Regular Intervals in a very detailed way.

Buy Me a Coffee

Online Web Tutor invites you to try Skillshike! Learn CakePHP, Laravel, CodeIgniter, Node Js, MySQL, Authentication, RESTful Web Services, etc into a depth level. Master the Coding Skills to Become an Expert in PHP Web Development. So, Search your favourite course and enroll now.

If you liked this article, then please subscribe to our YouTube Channel for PHP & it’s framework, WordPress, Node Js video tutorials. You can also find us on Twitter and Facebook.

Was this post helpful?

PHP Web Development Courses on Offer in just $4
PHP Web Development Courses on Offer in just $4