Friday, May 6, 2011

Making Events global instead of passing them in FF

Here's a good solution for an old old problem.

IE has always had window.event to allow you to grab an event from anywhere instead of passing it all over the place but Firefox and other 'standard compliant' browsers have been much less convenient. Well, here's the solution. Overwrite the window.event and its related properties. Here's a nice method to do it:

function mapEventToNS(e, win)
win.event = e;
win.event.srcElement =;
win.event.x = e.x;
win.event.y = e.y;
return true;