This is actually a browser compatibility problem, the root of Baidu in a large pile, briefly said that the event object in IE is a global variable, so where all can be used, but the WebKit kernel browser does not exist in this global variable event, but in the form of an implicit local variable (after the text will be described in detail ).
function myfunc (param) { alert (window.event);} // in IE type onclick= "myfunc (' TestIE ')" > // all normal //WebKit Browser, such as Chrome, typeonclicklike Firefox = "MyFunc (' Testwebkit ')" > // will prompt undefined
Then explain how the WebKit kernel's browser implicitly passes in the event object.
Or the above example, in the WebKit browser, onclick= "MyFunc (' Testwebkit ')" is actually equivalent to this:
onclick (event) { myfunc (' Testwebkit ');}
In other words, the No. 0 parameter of the OnClick method is actually the one that implicitly passes in the event object.
Then let's look at a call in the JS method: Arguments.callee.caller, where arguments is the parameter set of the method, Callee is the method that the current parameter is in, and caller is the method (or caller) that calls this method.
And then there's the correspondence:
function myfunc (param) { alert (Arguments.callee); // myfunc () alert (arguments.callee.caller); // onclick () Alert (arguments.callee.caller.arguments[0]); // Event } //WebKit Browser, such as Chrome,firefox <input type= "button" onclick= "MyFunc (' Testwebkit ') ">
In particular, Arguments.callee.caller can continue to pursue the caller, For example, Arguments.callee.caller.arguments.callee.caller is the pursuit of the first level. Why this is especially true, because there are times when you encounter a custom label, such as the case, if there are encapsulation and JS-related methods, The following may be the case:
onclick (event) { Tagcommand () { ///// In some cases, multi-layered nested myfunc (' Testwebkit ');} }
If you want to get the event object in the MyFunc method at this point, you need to go up to Level 2 and use arguments.callee.caller.arguments.callee.caller.arguments[0] to get it.
Solve an undefined problem with the window.event hint in the JS method in the WebKit browser