Automatically Refresh or Reload a Page using jQuery
In the first example, we are going to use the setTimeout() method to automatically reload and refresh a page. The setTimeout() method takes two parameters. In the first parameter, we will describe a function, which is used to contain code of reloading and refreshing the page. In the second argument, we will describe the time interval after which the execution of function takes place. The time interval should be in milliseconds. This method will execute the function a single time.
In the second example, we are going to use the setInterval() method to automatically reload and refresh a page. The setInterval() method takes two parameters. In the first parameter, we will describe a function, which is used to contain code of reloading and refreshing the page. In the second argument, we will describe the time interval, which is used to repeatedly call the function. The time interval should be in milliseconds. This method repeatedly executes the function after the given time interval until the clearInterval() is called or the window is closed. Here, we are not using any method to stop the execution of a function, which is specified in the setInterval() method. That means the method executes the function until we close the window.
In the third example, we are going to use Meta to automatically reload and refresh a page. Using the Meta tag, we can set the time in seconds. After that, we will target the page which we want to reload at the specified interval of time. If we want to a page into another page, we can use the URL to do this. If we don't specify the URL, we will be reloaded on the same page.
Now our above example is ready to run. When we run any of these examples, the following output will be generated:
We are from Javatpoint.com