刷新网页出错: 'X-Frame-Options' to 'deny'
javascript吧
全部回复
仅看楼主
level 1
Fun_3692 楼主
网上找到一段代码,定时刷新网页。
刷新某些网站时报错:
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);
}
2025年04月05日 03点04分 1
level 13
目标网页不支持在iframe中加载。这个HTTP响应头是对面网站服务器加上的,浏览器识别到这个头后拒绝在iframe中加载页面。
2025年04月05日 04点04分 2
是的。那么请问如何改进,能实现定时刷新网页呢?就像一些插件一样。
2025年04月05日 06点04分
1