简体   繁体   English

查找使用Firebug或其他工具导致某些操作的Javascript文件和行号

[英]Finding the Javascript file and line number that causes some action using Firebug or some other tool

Is it possible to use Firebug ( or some other tool ) to find out where some JS action came from ... ie which file and line. 是否可以使用Firebug(或其他工具)来找出一些JS动作来自哪里......即哪个文件和行。

For instance I have a button that causes a dropdown/slide and I want to find the Javascript that affected that drop down. 例如,我有一个按钮,导致下拉/滑动,我想找到影响该下拉列表的Javascript。 I know I can probably find it by doing a lot of detective work; 我知道我可以通过做很多侦探工作来找到它; but if it was CSS I was looking for then all I would have to do is to look in Firebug and it would give me the file and line number. 但如果是我正在寻找的CSS那么我要做的就是查看Firebug,它会给我文件和行号。 Is there any way of getting something similar for Javascript? 有没有办法为Javascript获得类似的东西?

Using the firequery plugin for firefox you might be able to find some information about what events are attached to certain elements. 使用firefox的firequery插件,您可能能够找到有关哪些事件附加到某些元素的信息。

Other than this your best way to approach the problem would be using console logs to pinpoint which element is firing the event. 除此之外,解决问题的最佳方法是使用控制台日志来确定触发事件的元素。 Maybe by searching for class names or id's on that element would be a good place to start. 也许通过在该元素上搜索类名或id是一个很好的起点。

In Chrome's Developer Tool, on the Elements tab, you'll see a column on the right with information about the selected element. 在Chrome的开发者工具中,在“元素”标签上,您会在右侧看到一列,其中包含有关所选元素的信息。 One of the panels is called Event Listeners which shows the events bound to an element and the source location. 其中一个面板称为事件监听器,它显示绑定到元素和源位置的事件。

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

相关问题 使用Firebug或替代工具查找已定义的JavaScript的位置 - Finding the location of defined JavaScript using Firebug or alternative tool 我可以使用javascript在每隔一行插入一些字符串吗? - Can I insert some string at every other line using javascript? 是否可以通过 WebKit、FireBug 或 IE8 开发工具等调试器来调试动态加载 JavaScript? - Is possible to debug dynamic loading JavaScript by some debugger like WebKit, FireBug or the IE8 Developer Tool? 为什么Firebug无法检测到某些JavaScript? - Why is Firebug unable to detect some JavaScript? 使用firebug在JavaScript中查找内存泄漏? - Finding memory leaks in JavaScript using firebug? 无限是javascript中的一些数字? - Infinity is some number in javascript? 为什么firebug会显示一些红色的javascript对象? - Why firebug shows some javascript objects in red color? 我可以防止使用JS Lint,JS Hint或其他工具将错误数量的参数传递给方法吗? - Can I prevent passing wrong number of parameters to methods with JS Lint, JS Hint, or some other tool? 如何使用javascript,jquery或其他一些javascript框架过滤数据? - How to filter data using javascript, jquery, or some other javascript framework? 对数组的每个元素执行一些操作,但使用 JavaScript 的一小部分 - Perform some action on each element of an array but in small portions using JavaScript
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM