简体   繁体   English

如何获取触发事件时执行的 JavaScript 文件列表?

[英]How to get a list of JavaScript files that are executed when event is fired?

In complicated system, how can I get a list of all the JavaScript files that has been fired during button click or click to input field?在复杂的系统中,如何获取在单击按钮或单击输入字段期间触发的所有 JavaScript 文件的列表?

Can I do it with chrome dev-tools or are there any other solutions?我可以用 chrome dev-tools 还是有其他解决方案? If I can do it with chrome dev-tools then how?如果我可以用 chrome dev-tools 做到这一点,那该怎么做?

Problem that I am facing : I am trying to find file what contains method which I can intercept to add my custom validation before button click redirects to another page?我面临的问题:我正在尝试查找包含方法的文件,在单击按钮重定向到另一个页面之前,我可以拦截该方法以添加我的自定义验证? File names are useful to me because the system is following clean code rules.文件名对我很有用,因为系统遵循干净的代码规则。

UPDATE: I found this tutorial , but none of provided solution seems to work (I am certain that breakpoints are not working).更新:我找到了本教程,但提供的解决方案似乎都不起作用(我确定断点不起作用)。 The Visual Event extension suggested by @Carles Alcove in referred post, lead me to knockout.js file.Visual Event扩展中提到通过后壁龛@Carles建议,使我knockout.js文件。 In that file I added console.trace() function (second image is the result) as suggested by @guest271314.在那个文件中,我按照@guest271314 的建议添加了console.trace()函数(第二张图片是结果)。 First image is when I inspected the button with dev-tools as suggested by @user3297291第一张图片是当我按照@user3297291 的建议使用 dev-tools 检查按钮时

在此处输入图片说明 在此处输入图片说明

您可以在click事件处理程序中包含console.trace()console.profile()console.profileEnd() ,在DevTools consoleProfiles选项卡中DevTools文件的行号

You can check an overview of event listeners attached to an element in the developer tools by doing:您可以通过执行以下操作来检查附加到开发人员工具中元素的事件侦听器的概述:

  • Right mouse button on an element元素上的鼠标右键
  • Inspect element in context menu检查上下文菜单中的元素
  • Click Event Listeners tab in the right panel of the dev.单击开发人员右侧面板中的事件侦听器选项卡。 tools工具
  • Check for mouseup or click events.检查mouseupclick事件。

在此处输入图片说明

You'll see the attached methods and their file names.您将看到附加的方法及其文件名。 I'm not sure if this works for every kind of event listener (eg if the event is bound to a parent element), but it's a quick way to predict what might be called.我不确定这是否适用于所有类型的事件侦听器(例如,如果事件绑定到父元素),但这是一种预测可能被调用的快速方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM