小玩意儿,有时候会用到,先记录一下吧

按键盘上F12,或者鼠标右键检查打开开发者模式,在console控制台中输入以下内容:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
var timeout = prompt("设置刷新时间间隔[S]");
// 获取当前的URL
var current = location.href;

if(timeout > 0)
{
// 时间间隔大于0,timeout秒之后执行reload函数
setTimeout('reload()', 1000 * timeout);
}
else
{
// 时间间隔不大于0,仅刷新一次
location.replace(current);
}

function reload()
{
// timeout秒后执行reload函数,实现无限循环刷新
setTimeout('reload()', 1000 * timeout);
// 下面两行代码的格式化后的内容为:
// <frameset cols='*'>
// <frame src='当前地址栏的URL' />
// </frameset>
var fr4me = '<frameset cols=\'*\'>\n<frame src=\'' + current + '\' />';
fr4me += '</frameset>';

with(document)
{
// 引用document对象,调用write方法写入框架,打开新窗口
write(fr4me);
// 关闭上面的窗口
void(close());
};
}

还可以修改var current = location.href中的location.href,实现刷新指定页面,
eg:> var current = “https://baidu.com

在弹出的窗口中,输入具体时间(秒),即可实现自动刷新网页