Page refresh after some delay in jquery

here is my problem: I need to display the message for a while and then reload the page. can someone tell me how to reload the page after a certain delay?

+11
source share
3 answers

You don’t even need jQuery or HTML5 for this:

setTimeout(location.reload.bind(location), 60000);

This will wait 1 minute (60,000 milliseconds), then call the function location.reload, which is a built-in function to refresh the page.

+35
source
setTimeout(function(){
    window.location.reload(); // you can pass true to reload function to ignore the client cache and reload from the server
},delayTime); //delayTime should be written in milliseconds e.g. 1000 which equals 1 second

Update:

Single line using ES6:

setTimeout(() => window.location.reload(), delayTime);
+15
source

js, :

<meta http-equiv="refresh" content="5"/> <!-- 5 sec interval-->
<h1>Page refersh in every 5 seconds...</h1>

, Google

<meta http-equiv="refresh" content="5;http://www.google.com"/> <!-- 5 sec delay-->
<h1>Redirecting in 5 seconds...</h1>
+4

Source: https://habr.com/ru/post/1545938/


All Articles