代码

var timeout = prompt("Set timeout (Second):");
var count = 0;
var current = location.href;
if (timeout > 0) {
    setTimeout('reload()', 1000 * timeout);
} else {
    location.replace(current);
}

function reload() {
    count++;
    console.log('每(' + timeout + ')秒自动刷新,刷新次数:' + count);
    var fr4me = '<frameset cols=\'*\'>\n<frame src=\'' + current + '\'/>';
    fr4me += '</frameset>';
    with (document) {
        write(fr4me);
        void(close())
    }
    setTimeout('reload()', 1000 * timeout);
}

 

回车

【JS】console定时刷新页面,不会因刷新而失效_JavaScript

 

 设置自动刷新时间,这里设置5秒

【JS】console定时刷新页面,不会因刷新而失效_MySQL_02

 

 【JS】console定时刷新页面,不会因刷新而失效_自动刷新_03

 

 

也可以在代码第一行直接设置自动刷新多少秒

 

参考文章:javascript:void(0)