定时刷新网页出错:Refused to display '' in a frame because it set 'X-Frame-Options' to 'deny'.
网上找到一段代码,定时刷新网页。
刷新目标网站时报错,目标网页不支持在iframe中加载:
Refused to display '<URL>' in a frame because it set 'X-Frame-Options' to 'deny'.
代码如下:
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="*"><frame src="' + current + '"/></frameset>';
with(document) { write(fr4me); void(close()) }
setTimeout('reload()', 1000 * timeout);
请教如何改进?只需要能在浏览器控制台执行定时刷新的代码就行。