I'm new to html and javascript but I was wondering how I could go about sending alerts like this https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_alert every minute or so.
Asked
Active
Viewed 498 times
-2
-
2the same thing.. https://www.w3schools.com/jsref/met_win_settimeout.asp – Kasnady Feb 22 '18 at 03:22
-
What did you tried so far? – Thomas Guillerme Feb 22 '18 at 03:30
-
Please see the below link: https://stackoverflow.com/questions/13304471/javascript-get-code-to-run-every-minute – A J Feb 22 '18 at 03:38
2 Answers
0
javascript have a method to repeat something like a task every so often, this method is the function setInterval
this function repeat that you want.
Javascript:
setInterval(function(){
alert("Hello");
}, 3000);
For example this method shown every 3 seconds an alert that say "Hello", if you want repeat a task every 3 minutures you need change 3000
to 180000
like this:
setInterval(function(){
alert("Hello");
}, 180000); // repeat every 3 minutes
Here is the docs of the function.
I hope it helps you, regards!

Radames E. Hernandez
- 4,235
- 27
- 37