Javascript 如何找到导致特定 UI 事件的函数调用?
我想找出是什么触发了事件。即,此网站 stackoverflow.com 上的通知栏(该栏会告诉您何时有人发布了对某个问题的回答)它从顶部缓慢向下滚动,并为用户通知提供了一个非常好的用户界面,我认为它可以在任何页面上工作
(我需要找到它的名称) 。 ):
special_notification( message );
简而言之,当所有的 javascript 都被缩小时,我如何去找出调用(函数名称和参数)是什么样子来产生这种效果,而且我不知道包含什么提供了它。
I want to find out what triggered an event. Namely, the notification bar on this site stackoverflow.com (the bar that tells you when someone has posted an answer to a question you're writing an answer on. It scrolls down slowly from the top and provides a really nice UI for user notifications. I've seen it work on just about ever page.
I imagine it working something (I need to find its name):
special_notification( message );
In the abstract, how do I go about finding out what the call (function name and arguments) looks like that generates that effect when all of the javascript is minified, and I have no idea what include provided it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
要阅读缩小的 js,您可以使用 http://jsbeautifier.org 之类的工具。
关于您的另一个问题,您想监听页面上的所有事件并知道是什么触发了它们以及执行的代码是什么?这是正确的吗?
更新:
没有办法监听所有事件。如果您确实需要,您可以为每个事件设置侦听器,但您仍然会错过自定义事件,我想这就是您所追求的。
我建议您使用 Firebug 检查代码以了解事件在每种情况下的使用方式。
您还可以侦听所有 DOM 事件,在 jQuery 中您将执行以下操作:
其中
e
将保存事件信息。希望这是有道理的。
To read minified js, you can use a tool like http://jsbeautifier.org.
Regarding your other concern, you want to listen to all the events on a page and know what triggered them and what is the code executed? is that correct?
Update:
There is no way to listen to all the events. If you really need to, you can set up listeners for every event, but you will still miss the custom events, which i guess are what you are after.
I'd suggest you inspect the code using Firebug to learn how the events are used in each case.
You can also listen to all the DOM Events, in jQuery you will do:
Where
e
will hold the event information.Hope that makes sense.