-2

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.

2 Answers2

1
setInterval(() => {
  // your code
}, 1000)

https://www.w3schools.com/jsref/met_win_setinterval.asp

Ru Chern Chong
  • 3,692
  • 13
  • 33
  • 43
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