Chrome debugging - break on next click event

一世执手 提交于 2019-11-26 18:46:00

问题


We have a button. Click events are handled by a 3rd party framework, however, the framework is buggy somehow.

We want to debug the framework, however, we don't know where the corresponding event handler code resides to set a breakpoint. How to generally "break on next click event" and see where and how this click is handled by the 3rd party framework?


回答1:


What you are looking for are 'Event Listener Breakpoints' on the Sources tab. These breakpoints are triggered whenever any event listener, that listens for chosen event, is fired. You will find them in the Sources tab. In your case, expand 'Mouse' category and choose 'Click'.




回答2:


What about a general approach ?
Type this in console:
document.body.onclick = function() { debugger; }

And you can extend that function as you like or attach it on different element in case you do not overwrite handler you are looking for ;-)



来源:https://stackoverflow.com/questions/18877190/chrome-debugging-break-on-next-click-event

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!