Firefox gets event

Source: Internet
Author: User

Because of the different browser to the JS file resolution, plus the various browser kernel is not the same, and the kernel version is not the same, so the way to get the event is not the same.

Getting the event using the original method is

Such a:

Document.body.onclick=function (e) {e=e| | window.event;};

In fact, you will want to re-assign the value because the event is instantaneous, so save it.

This method can be implemented, but ensure that the parameters passed are e.

There is another way to do this:

Upanddownlistener:function (obj) {var ev = document.all? window.event:event;if (Ev.keycode = =) {this.checkdouble (obj) ;d Efaulttrendgroup.trendredraw (); ev.returnvalue = false;}}

This time can be achieved to get the event, but in the Firefox browser has been error, but the program can be carried out.

The following is a way to solve the problem in the second way:


Upanddownlistener:function (obj) {var ev = document.all? Window.event:arguments[0]? Arguments[0]: Event;if (ev.keyCode = =) {this.checkdouble (obj);d efaulttrendgroup.trendredraw (); ev.returnvalue = false;}},

This way you can solve the problem in Firefox error.


For the above three ways, different ways can be used in different situations.


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Firefox gets event

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.