How to make the reload page take 10 seconds

0

I have this code here, but it is always reloading the page.

script type="text/javascript">
function autoRefreshPage()
{
    window.location = window.location.href;
    setInterval('autoRefreshPage()', 10000);
}

I wanted it to take 10 seconds to refresh the page when I clicked.

    
asked by anonymous 14.03.2018 / 18:45

1 answer

2

When doing

window.location = window.location.href;

The page will reload soon, failing to run setInterval; To fix it just change the function by:

function autoRefreshPage()
{
    setInterval(function () {location.reload();}, 10000);
}
    
14.03.2018 / 19:20