js alarm go to url

Solutions on MaxInterview for js alarm go to url by the best coders in the world

showing results for - "js alarm go to url"
Maria
22 Feb 2018
1function goUrlAlarm(time = '01:02:03', url) {
2  const today = new Date();
3  const month = today.getUTCMonth() > 9 ? today.getUTCMonth() : '0' + today.getUTCMonth();
4  const day = today.getUTCDate() > 9 ? today.getUTCDate() : '0' + today.getUTCDate();
5  const year = today.getUTCFullYear();
6  const second = today.getSeconds();
7  const minute = today.getMinutes();
8  const hour = today.getHours();
9  const x = new Date(`${year}-${month}-${day}T${time}`);
10  const y = new Date(`${year}-${month}-${day}T${hour}:${minute}:${second}`);
11  setTimeout(function () {
12    location.href = url;
13  }, x-y);
14}
15
16goUrlAlarm('12:00:00', 'http://google.com');
Youssef
22 Feb 2017
1function goUrlAlarm(time = '01:02:03', url) {
2  const today = new Date();
3  const month = today.getUTCMonth();
4  const day = today.getUTCDate();
5  const year = today.getUTCFullYear();
6  const x = new Date(`${year}-${month}-${day}T${time}`);
7  const t = new Date(x) - new Date();
8  setTimeout(function () {
9    location.href = url;
10  }, t);
11}
12
13goUrlAlarm('12:00:00', 'http://google.com');
queries leading to this page
js alarm go to urljs alarm go to url