捕获正在执行的特定javascript代码onClick [英] Catching the specific javascript code being executed onClick

查看:46
本文介绍了捕获正在执行的特定javascript代码onClick的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个包含大量遗留javascript和jquery包含的网站,并且没有文档显示发生了什么。

I am working on a site that has loads of legacy javascript and jquery includes and there is no documentation to show what is happening when.

我有一个特定的问题修复,我找不到单击按钮时正在执行的相关代码。为了避免拖延(并理解)数百行遗留脚本,是否有一个功能,可能在Firebug中,它将识别当我点击按钮时正在执行的脚本?

I have a specific problem to fix and I cannot find the relevant code that is being executed when a button is clicked. To save me from trawling through (and making sense of) hundreds of lines of legacy script, is there a feature, possibly in Firebug, that will identify what script is being executed when I click on a button?

感谢您的帮助。

推荐答案

我相信Firebug的控制台窗口中有一个名为资料。单击配置文件,单击按钮,然后再次单击配置文件。它应该为您提供当时所有函数的调用。请注意,如果此代码包含jQuery,您可能会获得大量的函数列表,因为jQuery在其代码中使用了吨。不幸的是,探查器也会显示匿名函数,这真的很麻烦。

I believe there is a feature in Firebug's console window called Profile. Click profile, click the button, then click profile again. It should give you what all functions were called in that time. Be warned that if this code includes jQuery, you might get a huge long list of functions because jQuery uses tons in its code. Unfortunately, the profiler will also show anonymous functions, which can really be a pain.

否则,在代码中搜索按钮的类或ID并通过它们。如果您的ID为 fancy ,那么您可以在代码中搜索 #fancy 并尝试查找。这可能会导致你进入一般方向,至少。

Otherwise, do a search in the code for the button's class or ID and go through them. If you have an id of fancy then you might do a search for #fancy in your code and attempt to find it. That may lead you in a general direction, at least.

这篇关于捕获正在执行的特定javascript代码onClick的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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