如果替换了本地获取
window.fetch = () => {}
如果不是我的代码的代码替换了本地获取,如何获取本地获取?
您不能在同一窗口中。但是您可以打开一个新窗口(可能为零高度iframe
)并从那里获取它:
const iframe = document.createElement("iframe");
iframe.src = "about:blank";
iframe.style.border = "none";
iframe.style.width = 0;
iframe.style.height = 0;
iframe.addEventListener("load", function() {
const realFetch = iframe.contentWindow.fetch;
// ...use `realFetch` here...
});