How to auto Refresh a Webpage in 30 sec


To auto-refresh a webpage every 30 seconds, you can use a simple HTML meta tag or JavaScript. Here are two methods you can use:

1. Using HTML Meta Tag:

Add the following meta tag to the head section of your HTML file:


<html>

<head>

    <meta http-equiv="refresh" content="30">

</head>

<body>

    <!-- Your webpage content goes here -->

</body>

</html>



The `content="30"` attribute in the meta tag tells the browser to refresh the page every 30 seconds.


2. Using JavaScript:

If you prefer using JavaScript, you can place the following script inside the `<head>` or `<body>` section of your HTML file:

<html>

<head>

    <script language="javascript">

setTimeout(function(){

   window.location.reload(1);

}, 30000);

</script>

</head>

<body>

    <!-- Your webpage content goes here -->

</body>

</html>

This JavaScript function `autoRefreshPage` will reload the page after waiting for 30 seconds (30000 milliseconds) using the `setTimeout` function.

Choose the method that suits your needs, and the webpage will automatically refresh at the specified interval. 

No comments:

Post a Comment