Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Refreshing a page after certain delay in jquery [duplicate]

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

like image 497
vnay92 Avatar asked Jun 25 '14 05:06

vnay92


People also ask

How do I refresh a page after some time?

Auto Refresh You can also use JavaScript to refresh the page automatically after a given time period. Here setTimeout() is a built-in JavaScript function which can be used to execute another function after a given time interval.

How can I refresh a page with jQuery?

Method 1: Using the location. reload(): The location. reload() method reloads the current web page emulating the clicking of the refresh button on the browser.

What is the use of delay () method in jQuery?

jQuery delay() Method The delay() method sets a timer to delay the execution of the next item in the queue.

How can I tell if jQuery is refreshing a page?

On Refresh/Reload/F5: If user will refresh the page, first window. onbeforeunload will fire with IsRefresh value = "Close" and then window. onload will fire with IsRefresh value = "Load", so now you can determine at last that your page is refreshing.


1 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 location.reload function, which is a built-in function to refresh the page.

like image 119
Scimonster Avatar answered Oct 08 '22 23:10

Scimonster