能帮忙给写一个吗? 我在网上找了好长时间都没有找到 随机刷新页面的,代码希望老师能帮忙给一写一个 

解决方案 »

  1.   

    不明白 随机函数是
    Math.random() 0-1之间的浮点数字
      

  2.   

    就是 在 30秒到 120秒之间 随机刷新一下页面我不会java script 麻烦大家给写一个吧
      

  3.   

    最后还是自己搞定了 贴出来
    <script language="JavaScript">total = 0
    for(i=1;i<=2000;i++)
    {num=Math.random();
    total +=num
    }
    average = total/2
    average = Math.round(average*1)/1
    //configure refresh interval (in seconds)
    var countDownInterval=average;
    //configure width of displayed text, in px (applicable only in NS4)
    var c_reloadwidth=200</script>
    <ilayer id="c_reload" width=&{c_reloadwidth}; ><layer id="c_reload2" width=&{c_reloadwidth}; left=0 top=0></layer></ilayer><script>var countDownTime=countDownInterval+1;
    function countDown(){
    countDownTime--;
    if (countDownTime <=0){
    countDownTime=countDownInterval;
    clearTimeout(counter)
    window.location.reload()
    return
    }
    if (document.all) //if IE 4+
    document.all.countDownText.innerText = countDownTime+" ";
    else if (document.getElementById) //else if NS6+
    document.getElementById("countDownText").innerHTML=countDownTime+" "
    else if (document.layers){ //CHANGE TEXT BELOW TO YOUR OWN
    document.c_reload.document.c_reload2.document.write('Next <a href="javascript:window.location.reload()">refresh</a> in <b id="countDownText">'+countDownTime+' </b> seconds')
    document.c_reload.document.c_reload2.document.close()
    }
    counter=setTimeout("countDown()", 1000);
    }function startit(){
    if (document.all||document.getElementById) //CHANGE TEXT BELOW TO YOUR OWN
    document.write('离下一次<a href="javascript:window.location.reload()">刷新</a>还有 <b id="countDownText">'+countDownTime+' </b>秒')
    countDown()
    }if (document.all||document.getElementById)
    startit()
    else
    window.onload=startit</script>
      

  4.   

    那个简单<!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>
        <title>无标题页</title>
    </head>
    <body>
    <script>
    function re()
    {
    location.reload();
    }
    document.body.onload=function()
    {
    var a=Math.floor(Math.random()*90)+30;
    a=a*1000;
    window.setInterval("re()",a);
    }
    </script>
    </body>
    </html>