我想在页面加载时停止执行window.location,如下所示:
<script type="text/javascript">
alert('Bid closed ');
window.location = '/index.html';
</script>
我能够通过在 manifest.json 中document_start
期间替换alert
函数来绕过alert
消息。但无法阻止窗口位置执行。
window
对象不可写,因此无法更改document
和window
对象查看此链接以获取更多信息
在我看来,答案就像一个数学难题。
在注入的脚本中,我刚刚放置了这段代码,它似乎可以工作:
window.alert =
function (msg)
{
throw Error('hello');
}
此异常导致浏览器跳过下一条语句window.location=