【发布时间】:2014-05-12 08:39:03
【问题描述】:
我需要创建一种特殊的脚本。
我想在一天中的特定时间显示一条消息。我已经在 Firebug 控制台中测试了代码并且它可以工作。代码是:
//Getting the hour minute and seconds of current time
var nowHours = new Date().getHours() + '';
var nowMinutes = new Date().getMinutes() + '';
var nowSeconds = new Date().getSeconds() + '';
var this_event = nowHours + nowMinutes + nowSeconds;
//172735 = 4PM 25 Minutes 30 Seconds. Just checked if now is the time
if (this_event == "162530") {
window.alert("Its Time!");
}
我觉得脚本不是每秒都在运行。为了使其有效工作,脚本必须能够检查小时分钟和秒“每秒”。我不担心表现,我只需要准确的时间(到秒)。
我该怎么做?
【问题讨论】:
标签: javascript greasemonkey userscripts