我正在使用 Microsoft Edge 扩展。
如果他们在特定的网址中导航,我会重定向用户。在我的 background.js 脚本中,我有这个:
browser.webNavigation.onBeforeNavigate.addListener(
function(details) {
if(details.url.indexOf("url_path") > -1){
alert("caught");
window.location = "http://new_url.com";
}
}
);
警报有效,但重定向无效。我做错了什么?在重定向中通过用户 e 通过 http auth 也是一个好主意吗?例如:windows.location = " http://user:pass@new_url.com " ?
谢谢 :)