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.
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.
No, you can't run anything in a tab that's been closed.
Use a server to do what you're trying to do.
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);
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