JS solution ie and Firefox for event incompatible functions

Source: Internet
Author: User

Solve the problem of incompatibility between IE and Firefox for event source

The code is as follows Copy Code

function GetEvent ()
{
if (document.all)
{
return window.event;
}
Func=getevent.caller;
while (Func!=null)
{
var arg0=func.arguments[0];
if (arg0)
{
if ((arg0.constructor==event | | arg0.constructor ==mouseevent)
|| (typeof (arg0) = = "Object" && arg0.preventdefault && arg0.stoppropagation))
{
return arg0;
}
}
Func=func.caller;
}
return null;
}

jquery compatible with IE and Firefox Firefox's carriage return event

The code is as follows Copy Code
$ (document). Ready (function () {
$ ("Press Enter Control"). KeyDown (function (e) {
var curkey = E.which;
if (Curkey = = 13) {
$ ("#回车事件按钮控件"). Click ();
return false;
}
});
});


jquery Multi-browser capture carriage return event code

The code is as follows Copy Code
$ (document). KeyDown (function (event) {
if (Event.keycode = = 13) {
$ (' form '). each (function () {
The code that you want to run
});
}
});


KeyUp event in Firefox the solution of incompatibility problem original writing:

The code is as follows Copy Code

$ (' #txt_nums_person '). KeyUp (function ()
{

Alert (' IE is incompatible with Firefox ');

});

Modify the wording:

The code is as follows Copy Code

$ (' #txt_nums_person '). Bind (' KeyUp ', function () {

Alert (' IE compatible Firefox is also compatible ');

});

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.