如何查看发生的 JavaScript 函数调用

发布于 2024-11-01 16:14:11 字数 208 浏览 5 评论 0原文

是否可以在浏览器的 JavaScript 控制台中查看 JavaScript 函数调用?我知道你可以查看XHR,但是你可以查看函数调用吗?

例如,我将鼠标悬停在页面上的某个元素上,就会弹出一个 div。我知道有一个 JavaScript 函数被调用来显示弹出窗口,因此如果能够在控制台中查看此调用就好了,这样我就可以看到调用了什么函数。

我错过了什么或者这是不可能的吗?

Is it possible to view JavaScript function calls in the browser's JavaScript console? I know you can view XHR, but can you view function calls?

For example, I hover my mouse over some element on a page and a div pops up. I know there was a JavaScript function that was called to show the popup so it would be nice to be able to view this call in the console so I can see what function was called.

Am I missing something or is this not possible?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

自由范儿 2024-11-08 16:14:11

那么基本上你想实时查看 JS 调用吗?

Firefox 上的 Firebug 扩展提供了这一点 (http://getfirebug.com/javascript)。

基本上,您想要做的就是在代码中找到您的函数,然后在其上设置断点。然后您应该能够单步执行它,就像普通的调试器一样。应该不难找到与特定事件(例如鼠标悬停)相关的 JS 函数 - 该页面是使用直接 JS 还是框架?如果有,是哪一个?

Google Chrome 的内置开发人员工具提供了一个较小的子集 - 根据您的需要,其上的“个人资料”选项卡可能有用吗?

您到底需要跟踪这个 JS 函数做什么?我们也许可以根据您的特定需求为您推荐更好的工具。

So basically you want to view JS calls in real-time?

The Firebug extension on Firefox offers that (http://getfirebug.com/javascript).

Basically, what you want to do is find your function within your code, then set a breakpoint on it. You should then be able to step through execution on it, just like a normal debugger. It shouldn't be hard to find the JS function associated with a and a particular event (e.g. mouseover) on that - is this page in question using straight JS or a framework? And if so, which one?

Google Chrome's built-in developer tools offer a smaller subset - depending on what you want, the Profile tab on it might be useful?

What exactly do you need to trace this JS function for? We might be able to recommend a better tool for you based on your particular need.

乖乖哒 2024-11-08 16:14:11

检查 Firebug Profiler,您可以使用它来查看正在发生的情况的详细信息,而无需手动添加 console.log 语句。

要使用探查器,只需转到“控制台”选项卡并单击“探查器”按钮。然后使用您的应用程序一段时间或重新加载页面,然后再次单击“个人资料”按钮。然后,您将看到一份详细报告,其中显示调用了哪些函数以及每个函数花费了多少时间。

http://michaelsync.net/ 2007/09/10/firebug-tutorial-logging-profiling-and-commandline-part-ii

了解 Firebug 分析器输出

Check into the Firebug Profiler you can use it to see a break down of what's going on without having to manually add in console.log statements.

To use the profiler, just go to the Console tab and click the "Profile" button. Then use your app for a bit or reload the page and then click the "Profile" button again. You'll then see a detailed report that shows what functions were called and how much time each one took.

http://michaelsync.net/2007/09/10/firebug-tutorial-logging-profiling-and-commandline-part-ii

Understanding Firebug profiler output

以酷 2024-11-08 16:14:11

除非您明确将该信息附加到 DOM,否则不会。

但是,您可以在某些浏览器的开发人员工具中设置断点,例如 Safari、Chrome 和 Firefox 的 Firebug。

Not unless you explicitly attach that information to the DOM.

You can, however, set breakpoints in the developers tools for some browsers, such as Safari, Chrome and Firebug for Firefox.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文