当我获取内容并立即重新加载页面时,网络预览将加载失败。
如果我将超时设置为1000ms,有时成功有时失败;
如果我将超时设置为3000毫秒,它将始终有效。
我猜错误是在读取数据时被刷新页面中断的。
因此,我可以捕获“信号”吗?呃,我的意思是“预览已加载信号”。
我已经启用了“保留日志”。
document.body.insertAdjacentHTML("afterbegin","<button>SEND</button>");
document.querySelector("button").onclick = () =>{
fetch("https://cors-anywhere.herokuapp.com/https://stackoverflow.com/").then(
r => r.text()
).then(
r => {
console.log(r.split("\n")[0]);
location.reload(); // Failed
// setTimeout(()=>{location.reload();}, 3000); // Success
}
)
}