Summary of how to obtain the event object in google explorer test_javascript tips-js tutorial

Source: Internet
Author: User
The Event object represents the Event status, such as the elements in the Event, the status of the keyboard buttons, the location of the mouse, and the status of the mouse button. The method to obtain the Event object is as follows, if you are interested, refer Introduction:

The Event object represents the Event status, such as the elements in the Event, the status of the keyboard buttons, the location of the mouse, and the status of the mouse button. Events are usually used in combination with functions. functions are not executed before an event occurs!
How to obtain the Event object:

Method 1:

For example:

The Code is as follows:


Function demo1 (e ){

Var e = e | window. event;

// This method can obtain the event either without passing the parameter e in ie or google, but the event parameter must be passed in the event Method in Firefox.

// To obtain the event object.

}



Method 2:Common and convenient methods (this method is convenient because parameters are not required)

For example:

The Code is as follows:


Function demo2 (){

Var e = arguments. callee. caller. arguments [0] | window. event;

// Arguments. callee indicates the current function body.

// Arguments. callee. caller is the upper-level function of the current function.

// When onclick = "demo2 ()" is executed, arguments. callee is demo2 (), arguments. callee. caller is function onclick,
// The first number of energy in onclick is event, that is, arguments. callee. caller. arguments [0.

}



Detailed Test summary:

I. The same omnipotent method is to pass the parameter event (the real parameter must be written with the event name but not the other name.

2. Windows. event is not supported by Firefox in ie and google browsers.

Iii. arguments. callee. caller. arguments [0] is only supported by Firefox and google. ie does not support this method.

From the above test results, we can see that google supports the above methods and is one of the most compatible browsers.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.