Reputation: 181
I have a requirement to write a task in javascript then make it run after every 30 minutes even after the web page is closed. So is there any solution for this?
Thanks in advance.
Upvotes: 1
Views: 96
Reputation: 1739
You have an option of using web workers/shared web workers for this purpose. But you should have atleast one active tab for web worker to run, shouldn't close the browser completely.
Check out the below examples
Upvotes: 0
Reputation: 2153
Or you can use onbeforeunload
event to do something before the page closes.
window.onbeforeunload = function(){
// Do something
}
// OR
window.addEventListener("beforeunload", function(e){
// Do something
}, false);
Upvotes: 1
Reputation: 14275
No, you can't run anything in a tab that's been closed.
Use a server to do what you're trying to do.
Upvotes: 2