var d = new Date();
h = d.getHours();if (h > 0 && h <=3)
{
document.write('0');
}
if (h > 3 && h <=6)
{
document.write('1');
}
if (h > 6 && h <=9)
{
document.write('3');
}
 if(h > 9 && h <=12)
{
document.write('19288');
}
 if(h > 12 && h <=13)
{
document.write('19322');
} if(h > 15 && h <=18)
{
document.write('18');
}
 if(h > 18 && h <=21)
{
document.write('27');
}
 if(h > 21 && h <=23)
{
document.write('32');
}
现在这个js  显示是是根据固定时间然后显示数字,请问下如何修改这段代码让每隔10分钟 或者20分钟==然后变化数字,
现在是每隔小时变换一次  要修改下按分钟。。求指点   

解决方案 »

  1.   

    // 这是1分钟刷一次
    window.setInterval(xxx, 60000);function xxx() {
      你上面贴出来的js写在这里
    }
      

  2.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    </head><body>
    <span id="demo"></span>
    <script type="text/javascript">
    function f() {
    var d = new Date();
    h = d.getHours();
    var obj = document.getElementById('demo');

    if (h > 0 && h <= 3) obj.innerHTML = '0';
    if (h > 3 && h <= 6) obj.innerHTML = '1';
    if (h > 6 && h <= 9) obj.innerHTML = '3';
    if (h > 9 && h <= 12) obj.innerHTML = '19288';
    if (h > 12 && h <= 13) obj.innerHTML = '19322';
    if (h > 15 && h <= 18) obj.innerHTML = '18';
    if (h > 18 && h <= 21) obj.innerHTML = '27';
    if (h > 21 && h <= 23) obj.innerHTML = '32';
    }f();
    setInterval('f()', 10 * 60 * 1000);
    </script>
    </body>
    </html>