請問下,我想在頁面加載後,1 秒後讓頁面再自動重刷新一次,可是我用這個段代碼後卻變成了反覆刷新
setTimeout(function(){window.location.reload()},1000);
本來setTimeout不是應該只執行一次的麼?

解决方案 »

  1.   

    你这个肯定是反复刷新了!你页面刷新了setTimeout(function(){window.location.reload()},1000);
    也刷新了!所以又得执行了!
      

  2.   

    function queryString(key)
    {
        var regex_str = "^.+\\?.*?\\b"+ key +"=(.*?)(?:(?=&)|$|#)"
        var regex = new RegExp(regex_str,"i");
        var url = window.location.toString();
        if(regex.test(url)) return RegExp.$1;
        return undefined;
    }var f = queryString("f");
    if(!f)
    {
        window.setTimeout(function(){window.location=window.location.toString()+"?f=1"},1000)
    }
      

  3.   


    adTimer=setTimeout(function(){window.location.reload();clearInterval(adTimer)},1000);
      

  4.   

    试试这样<script type="text/javascript">
       function onload() {        function getQueryString(name) {
                var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
                var r = window.location.search.substr(1).match(reg);
                if (r != null) return unescape(r[2]); return null;
            }
            
            if (getQueryString('do') != 'true') {            
               
                setTimeout(function () { window.location.href = window.location + '?do=true'; }, 1000);
            }    };</script>
      

  5.   

    有的页面的链接使用了url传参的,那些页面的我改成“&do=true”就可以了,谢谢至尊宝老兄