如何追踪像onclick onblur这样的JavaScript事件? [英] How to trace JavaScript events like onclick onblur?

查看:106
本文介绍了如何追踪像onclick onblur这样的JavaScript事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个错误,可以防止在文本选择后滚动,而我不知道哪个事件或动作会产生错误。我真的想看看当我移动鼠标时触发了哪些事件。



重新连接源代码太多了,我希望有一个像嗅探器的东西,显示我触发的所有事件。

解决方案

Borkdude说:


你可能想尝试Visual Studio 2008及其功能来调试JavaScript代码。


我一直在多次对事件处理进行黑客攻击,在我看来,尽管经典的步进调试器对跟踪长代码运行非常有用,它们跟踪事件并不好。想象一下,在每一个事件上都会听到鼠标移动事件并突破另一个应用程序...所以在这种情况下,我强烈建议您进行日志记录。


如果问题不是特定于Internet Explorer 7,而且也发生在Firefox中,那么调试JavaScript代码的另一个好方法是Firefox和 Firebug 附加组件,其中有一个JavaScript调试器。


还有一个 Firebug Lite 的Internet Explorer。我没有机会使用它,但它存在。 :-)它的缺点是它不是一个完全成熟的调试器,但它有一个window.console对象,这正是您需要的。


Is there a way to debug or trace every JavaScript event in Internet Explorer 7?

I have a bug that prevents scrolling after text-selecting, and I have no idea which event or action creates the bug. I really want to see which events are being triggered when I move the mouse for example.

It's too much work to rewire the source and I kind of hoped there was something like a sniffer which shows me all the events that are triggered.

解决方案

Borkdude said:

You might want to try Visual Studio 2008 and its feature to debug JavaScript code.

I've been hacking around event handling multiple times, and in my opinion, although classical stepping debuggers are useful to track long code runs, they're not good in tracking events. Imagine listening to mouse move events and breaking into another application on each event... So in this case, I'd strongly advise logging.

If the problem is not specific to Internet Explorer 7 but also occurs in Firefox, then another good way to debug JavaScript code is Firefox and the Firebug add-on which has a JavaScript debugger.

And there's also Firebug Lite for Internet Explorer. I didn't have a chance to use it, but it exists. :-) The downside of it is that it doesn't a fully-fledged debugger, but it has a window.console object, which is exactly what you need.

这篇关于如何追踪像onclick onblur这样的JavaScript事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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