Getting event object in inline onclick event
Yesterday i need to get event object for onclick event and onclick event was written inline.
After investing an hour i got methods for that.
I’m writing here for all, who needs that.
click me
to get event object for inline events you have to pass
window.event
so to make your function cross browser compatible you can add following code in your function
function xyz(e){
var e = e ? e : window.event; // now here e is the event object
}
a more appropriate example is
A right example of the this post by earni is like this
this same function will also work for non inline onclick events
0 ResponsesLeave a comment ?