[英]What is the fastest way to find a listener for debugging javascript in a browser?
Background:背景:
I often find myself in the position of debugging a piece of Java script on a web page in an unfamiliar codebase, and often one that has seen many developers and coding approaches.我经常发现自己在一个陌生的代码库中调试网页上的一段 Java 脚本,而且通常是一个见过许多开发人员和编码方法的代码库。 Sometimes I do not even what technologies might be in use, eg.
有时我什至不知道可能正在使用什么技术,例如。 angular etc.
角度等
The first time I need to address the Java script is when a specific behaviour is unexpected (ie. it has gone wrong.)我第一次需要处理 Java 脚本是在特定行为出乎意料(即出错)时。
Question: What tool provides the fastest route to identifying the entry point of the code that is causing the problem?问题:什么工具提供了最快的途径来识别导致问题的代码的入口点?
Example: I have an html element on a page lets say a button.示例:我在页面上有一个 html 元素,可以说是一个按钮。 When that button is clicked I expect to see an http request at the server.
单击该按钮时,我希望在服务器上看到一个 http 请求。 There are many ways the element can be associated with its Java script listener.
元素可以通过多种方式与其 Java 脚本侦听器相关联。 eg JQuery, thrid party plugins such as knockout etc, in house scripts, and so on.
例如 JQuery、第三方插件(如 knockout 等)、内部脚本等。
Using developer tools I can start debugging this in the browser but only if I already know the entry point to put a breakpoint on.使用开发人员工具,我可以在浏览器中开始调试它,但前提是我已经知道要放置断点的入口点。
Is there a faster method to find the entry point than doing regular expressions searches on the pages code based on intuition and guess work to find what might be attached to that particular element?有没有比基于直觉和猜测工作在页面代码上进行正则表达式搜索以找到可能附加到该特定元素的内容更快的方法来找到入口点?
For me, the best starting point is in Chrome developer tools.对我来说,最好的起点是 Chrome 开发者工具。 You can:
你可以:
click
)click
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.