As we all know, there are two ways to get event objects on a webpage. One is to access the window. Event attribute, and the other is the first parameter of the event function.
IE only supports window. event, Firefox only supports the form of parameters, while other mainstream browsers support both. Therefore, for compatibility with FF, it is generally written:
Function handle (e) {e = E | event ;...}
Although this can be run in most cases, there is a problem with embedded calls. For example, , although we can pass arguments [0] as a parameter, this is usually used here, because handle may be bound to multiple elements. Although there are some solutions, but after all it is troublesome, it is better to do a permanent solution for Firefox: add an event attribute (getter) to his window ):
If (is FF ..) {var $ e = function () {var c = $ E. caller; while (C. caller) C = C. caller; return C. arguments [0]}; _ definegetter _ ("Event", $ E );}
Every time Firefox accesses the event attribute, it will access the top-level function along the call stack, that is, the function that captures the event. The first parameter of this function is the event object. In this way, all browsers can use the event attribute, without code like e = E | event.