I am working on a greasemonkey script for gmail where i need to make a copy of the "Inbox" link. Using cloneNode works ok, but i think there's an onclick event that gets attached to it at runtime. So, this is a two part question: 1. Is there a way to see what events are attached to a node? 2. Is there a way to copy those events as well? The closest thing i found was jQuery, and i am not ready to go there yet. Thanks!
+3
A:
- Not unless it's set using the
onclick
attribute on the element. - Not reliably (you can copy the
onclick
attribute, but whether that will continue to work depends on if it was used and what it does).
You're better off adding your own click
handler, and then triggering that event on the original... Or simulating the behavior in some other way.
Shog9
2009-05-02 21:29:42
I considered simulating the click event as well, but i can't find a reliable way of doing that either.
Pasha
2009-05-02 21:33:35
https://developer.mozilla.org/en/DOM/element.dispatchEvent
Shog9
2009-05-02 21:37:33
That's what i was looking for! I can just dispatch the click even on the original node. Thank you very much!
Pasha
2009-05-02 21:59:19