How to make Reload page take 10 seconds

Asked

Viewed 197 times

0

I have this code here, but it is always doing the page re-load.

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

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

  • Take a look: https://github.com/kidh0/jquery.idle

  • Click where????

  • @Juniornunes Why complicate if the code can be easily adapted to be correct?

1 answer

2


In doing

window.location = window.location.href;

The page will reload soon, stopping running the setInterval; To fix just change the function by:

function autoRefreshPage()
{
    setInterval(function () {location.reload();}, 10000);
}
  • Correct answer, thank you!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.