0

我在 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); 

}

谢谢

4

2 回答 2

0

我最终使用此脚本解决了它,将其设置为 1 小时并在 1 分钟后上传... Simples

//在“分钟:秒”中输入刷新时间分钟应该从0到无穷大。秒的范围应为 0 到 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+" 分钟和 "+cursec+" 秒离开直到页面刷新!” else curtime=cursec+" 距离页面刷新还剩几秒!" window.status=curtime setTimeout("beginrefresh()",1000) } }

window.onload=开始刷新

于 2010-10-13T09:19:53.023 回答
0

您已经将页面加载到一个框架中,没有必要让这比应该的更难,只需使用设置为 20 分钟左右的元刷新。

于 2010-10-12T00:36:11.433 回答