页面刷新之前是否有断点? [英] Breakpoint right before page refresh?

查看:200
本文介绍了页面刷新之前是否有断点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在调试一些第三方精简Javascript,该Javascript某处正在触发浏览器页面刷新。但是,我无法弄清楚代码的哪一部分会导致刷新。

I'm debugging some 3rd-party minified Javascript that somewhere is triggering a browser page refresh. However, I can't figure out what part of the code is causing the refresh.

有没有办法在Chrome中放置一个断点,该断点会在页面刷新,以便我可以检查调用堆栈以查看是什么原因造成的?

Is there a way to put a breakpoint in Chrome that will be hit just before a page refresh so I can inspect the call stack to see what caused it?

推荐答案

尝试以下操作:


  1. 打开您的Chrome开发工具

  2. 导航至来源标签

  3. 在右侧面板上,展开事件监听器断点。

  4. 展开加载树

  5. 检查 beforeunload unload 选项

  1. Open your Chrome Dev Tools
  2. Navigate to the "Sources" tab
  3. On the right panel, expand "Event Listener Breakpoints"
  4. Expand the "Load" tree
  5. Check the beforeunload and unload options

看看是否有帮助;下面的屏幕截图。

See if that helps; screenshot below.

编辑:或者,如果没有不起作用,您可以使用Chrome浏览器在所有加载的脚本中搜索可能负责的代码。显然,有有很多方法可以使用JavaScript刷新页面,但是它们大多具有一些常见的字符串,例如 navigator,

Alternately, if that doesn't work, you can use Chrome to search all loaded scripts for the code that might be responsible. There's apparently a lot of ways to refresh the page with JavaScript but they mostly have a few common strings like "navigator", "location", "reload", "window".

最后,如果有指向您所在页面的链接,则可能是某些JS触发了对其的点击-不太可能,但是值得探索到目前为止是否还没有其他方法...

Finally, if there's a link to the same page you are on, it's possible some JS is triggering a click on it-- unlikely, but worth exploring if nothing else has worked thus far...

(请原谅我在移动设备上使用的格式...)

(Please excuse the formatting as I'm on mobile...)

注意:有时,由于我尚未完全理解的原因,该解决方案实际上无法导致调试器暂停;在这种情况下,我发现thorn̈对这个问题的回答可以解决问题我。

NOTE: It seems occasionally, for reasons I don't yet fully understand, this solution fails to actually cause the debugger to pause; in this situation, I found that thorn̈'s answer to this question did the trick for me.

这篇关于页面刷新之前是否有断点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆