开发者

Custom events and who's the sender?

开发者 https://www.devze.com 2023-01-11 12:14 出处:网络
I\'m using a component written in JavaScript. The component is exposing some events. The problem is I can\'t figure out who is the sender. They don\'t provide an instance of the sender as a parameter

I'm using a component written in JavaScript. The component is exposing some events. The problem is I can't figure out who is the sender. They don't provide an instance of the sender as a parameter (like jQuery does).

My question is: Is 开发者_如何学JAVAthere any way to hook up the event using JavaScript/jQuery or any other way to get the sender?

All I know is the event name.


If I am correct in what you want: event.srcElement

http://msdn.microsoft.com/en-us/library/ms534638%28VS.85%29.aspx

Note: This does not work in Firefox.

For FF and most likely Webkit:

img.onclick = function (e) { 
 if (window.event) e = window.event; 
 var srcEl = e.srcElement? e.srcElement : e.target; 
 // srcEl now can be used x-browser.  
 // (rest of the script here) 
}
0

精彩评论

暂无评论...
验证码 换一张
取 消