代码

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定时刷新页面,不会因刷新而失效

 

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

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

 

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

 

 

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

 

参考文章:https://blog.csdn.net/jiang18238032891/article/details/103917553

相关文章:

  • 2021-11-19
  • 2021-06-24
  • 2022-12-23
  • 2022-12-23
  • 2021-04-04
猜你喜欢
  • 2021-11-19
  • 2021-11-19
  • 2021-11-19
  • 2022-12-23
  • 2022-12-23
  • 2021-12-08
相关资源
相似解决方案