gpt4 book ai didi

javascript - 如何在一天中的特定时间自动刷新 wordpress 页面

转载 作者:行者123 更新时间:2023-11-30 14:08:53 25 4
gpt4 key购买 nike

我想在每天晚上 8:59 的特定时间刷新我的 wordpress 主页。我对 CSS 和 HTML 略有了解,但对 Javascript 几乎一无所知,所以如果您能详细解释解决方案,那将非常有帮助。

具体用例是我要嵌入预定的 Facebook 实时流,如果用户在流开始之前已经加载了网站,则需要刷新。我们的节目在晚上 9 点开始,直播在 8:59 开始,所以如果我们可以在 8:59 强制自动刷新,我们就可以确保没有人错过直播(我们的观众主要由年纪不大的人组成精通技术)。

提前致谢!

最佳答案

 setInterval(function(){
const date = new Date();

const hour = date.getHours();
const minute = date.getMinutes();

console.log(hour, minute);

if(hour == 8 && minute == 59){
location.reload();
}
},1000);

Returns the hour in the specified date according to local time. If UTC is desired, use new Date(Date.UTC(...)) with the same arguments.

关于javascript - 如何在一天中的特定时间自动刷新 wordpress 页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54847193/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com