Auto Refresh Code in HTML Using Meta Tags

How do I refresh my html page every 2 mins?

You can use:

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


The <meta http-equiv="refresh"> tag causes a web page to refresh
automatically after a specified amount of time. Users generally don't
expect automatic refreshes, so they can be disorienting. Refreshing
also moves focus to the top of the page, which may frustrate or
confuse users, particularly those who rely on screen readers or other
assistive technologies.

  • https://web.dev/meta-refresh/
  • Meta equiv refresh

HTML meta stop auto refresh after onclick button

Use JS for that:

var timer = setTimeout(function () {
window.location.reload()
}, 60000);

This code will reload your webpage after 60 milliseconds.

You can cancel reload using it's reference timer:

clearTimeout(timer);

Refresh HTML page automatically

There are known problems where this will not work with some versions of IE. There is a kind of hack where you put a second head section containing the appropriate meta tag, at the end of the HTML document.

Refresh HTML Page in Browser Automatically on Timer - Every 15 Min

Place this inside <head> to refresh page after 900 seconds:

<meta http-equiv="refresh" content="900"> <!-- Refresh every 15 minutes -->

For what it's worth, the w3c has officially deprecated this feature, but browsers continue to support this feature. For your purposes, this is an ideal solution. It's just not a recommended solution for "public" (www)-facing web sites any more.



Related Topics



Leave a reply



Submit