dongqie4402 2016-03-21 02:19
浏览 40

当功能定时器到达00:00时刷新div

I'm trying to make it so that when the stime function reaches 00:00, the div id "refresh" will refresh the content inside..

<script type="text/javascript">
var currenttime = '<? print date("F d, Y H:i:s", time())?>'
var montharray=new 
var serverdate=new Date(currenttime)

function stime(){
var fiveMinutes = 5 * 60 * 1000;
var untilNext = fiveMinutes - (serverdate % fiveMinutes);
var timer=(untilNext / 1000)
var minutes= "0" + Math.floor(untilNext / 1000 / 60)
var seconds= "0" + (timer - minutes * 60)
document.getElementById("stime").innerHTML=minutes.substr(-2)+":"+seconds.substr    (-2)
}

window.onload=function(){
setInterval("stime()", 1000)
}
</script>

<?php
echo '<div id="refresh">Health: <span style="float:right" id="stime"></span></div><br />';
?>

My Question

Is it possible with that function, to make another function that would refresh the div when the stime function reaches 00:00 ?

  • 写回答

2条回答 默认 最新

  • duanqi5114 2016-03-21 02:24
    关注

    Make your setInterval like this:

    window.onload=function(){
        setInterval(stime, 1000)
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 STM32单片机自主设计
  • ¥15 如何在node.js中或者java中给wav格式的音频编码成sil格式呢
  • ¥15 不小心不正规的开发公司导致不给我们y码,
  • ¥15 我的代码无法在vc++中运行呀,错误很多
  • ¥50 求一个win系统下运行的可自动抓取arm64架构deb安装包和其依赖包的软件。
  • ¥60 fail to initialize keyboard hotkeys through kernel.0000000000
  • ¥30 ppOCRLabel导出识别结果失败
  • ¥15 Centos7 / PETGEM
  • ¥15 csmar数据进行spss描述性统计分析
  • ¥15 各位请问平行检验趋势图这样要怎么调整?说标准差差异太大了