
6

js 怎样阻止页面中其它 js 的自动跳转并不弹出任何提示?
source link: https://www.v2ex.com/t/1005033
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

4 条回复 • 2024-01-02 11:20:01 +08:00
![]() |
paledream 2 小时 33 分钟前 ```js
window.onbeforeunload = () => false; ```` 这样试试 |
Melting 1 小时 42 分钟前 要阻止可以覆盖原来的跳转函数逻辑,比如重写 setTimeout 或者 window.open
|
ljtfdt 1 小时 36 分钟前 1 、先看一下 b.js 里面的跳转逻辑,看看是使用那个函数来实现跳转
2 、让 a.js 先于 b.js 加载 3 、在 a.js 中覆盖 b.js 中使用的函数 |
![]() |
Liam1997 9 分钟前 如果仅仅是为了完成需求的话,chrome 浏览器打开 network 面板就可以 block 掉指定资源了,也就是你这里所说的 b.js ,这个方案是最无脑、最快的 ?
麻烦点的话,可以用 chrome search 下 b.js 里相关跳转代码(.open 、.href = 'xxx' 这种),然后加断点进行调试,定位到之后就很好办了,用 Charles 等代理工具或者 Chrome 内置的资源覆盖能力每次访问该网站的时候用本地 js override 掉 b.js |
</div
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK