📜  js 警报转到 url - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:59.853000             🧑  作者: Mango

代码示例1
function goUrlAlarm(time = '01:02:03', url) {
  const today = new Date();
  const month = today.getUTCMonth();
  const day = today.getUTCDate();
  const year = today.getUTCFullYear();
  const x = new Date(`${year}-${month}-${day}T${time}`);
  const t = new Date(x) - new Date();
  setTimeout(function () {
    location.href = url;
  }, t);
}

goUrlAlarm('12:00:00', 'http://google.com');