是否可以拦截 document.location.href = "http://my.domain";
发出的请求并添加授权 header ?如果有帮助的话我正在使用 ReactJS。谢谢。
最佳答案
否,一旦调用此代码
document.location.href = "http://my.domain"
没有办法拦截(假设拦截
你的意思是 stopping it from happening )这个调用。
但是您可以 catch 事件unload
window.addEventListener('beforeunload', function(event) {
console.log('I am the 1st one.');
});
window.addEventListener('unload', function(event) {
console.log('I am the 3rd one.');
});
关于Javascript - 我可以拦截对 document.location.href 的调用吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34942271/