Search code examples
htmlmeta

HTML meta stop auto refresh after onclick button


I am using a very simple html auto refresh as below to auto trigger refresh my webpage. This function works perfectly until I onClick on any html button on the same page, the page will stop auto refresh.

<meta http-equiv='refresh' content='60'>

As a simple summary, the auto refresh function will stop working if there is any action triggered on the page alike clicked a button on the page. Any solution on this issues?


Solution

  • 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);