在 Joomla 中刷新
我在 Apache/2.2.9 (Unix) mod_ssl/2.2.9 服务器上有一个 Joomla 站点,我希望它每小时过 1 分钟刷新页面,以确保显示最新的文章,这是一个广播网站,所以听众经常在网站上打开浏览器几个小时。 此代码片段是否可以调整为每小时过 1 分刷新?
function refreshAt(hours, minutes, seconds) {
var now = new Date();
var then = new Date();
if(now.getHours() > hours ||
(now.getHours() == hours && now.getMinutes() > minutes) ||
now.getHours() == hours && now.getMinutes() == minutes && now.getSeconds() >= seconds) {
then.setDate(now.getDate() + 1);
}
then.setHours(hours);
then.setMinutes(minutes);
then.setSeconds(seconds);
var timeout = (then.getTime() - now.getTime());
setTimeout(function() { window.location.reload(true); }, timeout);
}
谢谢
i have a Joomla site on a Apache/2.2.9 (Unix) mod_ssl/2.2.9 server and i would like it to refresh the page at 1 miniute past each hour to ensure the latest articles are shown, this is a radio website so listeners often have their browser open on the site for hours at a time.
Can this snippet be adapted to refresh at 1 miniute past each hour?
function refreshAt(hours, minutes, seconds) {
var now = new Date();
var then = new Date();
if(now.getHours() > hours ||
(now.getHours() == hours && now.getMinutes() > minutes) ||
now.getHours() == hours && now.getMinutes() == minutes && now.getSeconds() >= seconds) {
then.setDate(now.getDate() + 1);
}
then.setHours(hours);
then.setMinutes(minutes);
then.setSeconds(seconds);
var timeout = (then.getTime() - now.getTime());
setTimeout(function() { window.location.reload(true); }, timeout);
}
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您已经将页面加载到框架中,没有必要让这变得比应有的困难,只需将元刷新设置为 20 分钟左右即可。
You are already loading the pages in to a frame, no point in making this harder than it should be, just use a meta refresh set to 20 minutes or so.
我最终使用这个脚本解决了这个问题,将其设置为 1 小时并在过去 1 分钟上传... Simples
//以“分钟:秒”为单位输入刷新时间 分钟应范围从 0 到无穷大。秒的范围应为 0 到 59
var limit="60:0"
if (document.images){
var parselimit=limit.split(":")
parselimit=parselimit[0]*60+parselimit[1]*1
}
函数开始刷新(){
if (!document.images)
返回
if (解析限制==1)
window.location.reload()
别的{
解析限制-=1
curmin=Math.floor(parselimit/60)
curec=parselimit%60
如果(柯明!=0)
curtime=curmin+" 距离页面刷新还剩几分钟和 "+cursec+" 秒!"
别的
curtime=cursec+" 页面刷新还剩几秒!"
window.status=当前时间
setTimeout("开始刷新()",1000)
}
window.onload
=开始刷新
i solved it in the end using this script, setting it to 1hr and uploading it 1 minute past... Simples
//enter refresh time in "minutes:seconds" Minutes should range from 0 to inifinity. Seconds should range from 0 to 59
var limit="60:0"
if (document.images){
var parselimit=limit.split(":")
parselimit=parselimit[0]*60+parselimit[1]*1
}
function beginrefresh(){
if (!document.images)
return
if (parselimit==1)
window.location.reload()
else{
parselimit-=1
curmin=Math.floor(parselimit/60)
cursec=parselimit%60
if (curmin!=0)
curtime=curmin+" minutes and "+cursec+" seconds left until page refresh!"
else
curtime=cursec+" seconds left until page refresh!"
window.status=curtime
setTimeout("beginrefresh()",1000)
}
}
window.onload=beginrefresh