在 Joomla 中刷新

发布于 2024-09-27 00:26:08 字数 743 浏览 2 评论 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); 

}

谢谢

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

执妄 2024-10-04 00:26:08

您已经将页面加载到框架中,没有必要让这变得比应有的困难,只需将元刷新设置为 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.

甜味超标? 2024-10-04 00:26:08

我最终使用这个脚本解决了这个问题,将其设置为 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文