使用Firefox,我如何监视所有被触发的JavaScript事件? [英] Using Firefox, how can I monitor all JavaScript events that are fired?

查看:988
本文介绍了使用Firefox,我如何监视所有被触发的JavaScript事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图调试一个大量使用JavaScript事件的网页,所以我需要监视所有被触发的JavaScript事件。

大多数事件绑定使用jQuery。因此,如果有一种方法可以专门监视那些事件,那将是特别有用的。

当然,你可以做罚款与插件来查看DOM中的哪些元素附有jQuery事件,以及他们是。



正如benvie的回答所提到的,在webkit的开发工具中也是如此。


I'm trying to debug a webpage that makes heavy use of JavaScript events, and so I need to monitor all JavaScript events that are fired.

Most of the events are bound using jQuery. Hence, it would be particularly useful if there was a way to specifically monitor only those events.

解决方案

Of course you can do just fine with Firebug, the console and the scripts tab where you can add breakpoints and watches, but you want to do it smarter / easier obviously.

There is a neat Firebug plugin called EventBug that just logs all the events and groups them by event type so you can expand and see what triggered them.

EventBug doesn't do it realtime, you have to refresh though.

One other way is to use the 'Log Events' feature against any DOM element in Firebug. This does do it realtime and you can see what order events are fired / triggered as well.

Try this:

  • Toggle open Firebug
  • Right click the element in HTML tab, if you want to see all events then right click <body>
  • Choose Log Events from the context menu
  • Make sure the Console tab is enabled
  • Click to enable the 'Persist' mode in the Console tab (otherwise Console tab will clear after the page is reloaded)
  • You may have to select Closed (manually)
  • Voila! watch events stream in the console tab

This is what you see with Log Events:

Also worth trying the FireQuery add-on for Firebug to see what elements in the DOM have jQuery events attached to them and what they are.

And as benvie's answer mentions, this is possible in webkit's developer tools as well.

这篇关于使用Firefox,我如何监视所有被触发的JavaScript事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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