Ctrl+enter Submission--compatible with Firefox, ie, opera

Source: Internet
Author: User

Ctrl+enter Submission--compatible with Firefox, ie, opera

function Iskeytrigger (e,keycode) {
var argv = iskeytrigger.arguments;
var argc = isKeyTrigger.arguments.length;
var bCTRL = false;
if (argc > 2) {
bCTRL = argv[2];
}
var Balt = false;
if (argc > 3) {
Balt = argv[3];
}

var nav4 = window. Event? True:false;

if (typeof e = = ' undefined ') {
e = event;
}

    if (bCTRL &&
       ! ( (typeof E.ctrlkey!= ' undefined ')?
            E.ctrlkey:e.modifiers & Event.control_ MASK > 0)) {
        return false;
   }
  & nbsp if (Balt &&
       ! ( (typeof E.altkey!= ' undefined ')?
            E.altkey:e.modifiers & Event.alt_mask > 0)) {
        return false;
   }
     var whichcode = 0;
    if (nav4) Whichcode = E.which;
    Else if (E.type = "KeyPress" | | | e.type = = "KeyDown")
      &nb Sp Whichcode = E.keycode;
    Else Whichcode = E.button;

return (Whichcode = = KeyCode);
}

function Ctrlenter (e) {
var ie =navigator.appname== "Microsoft Internet Explorer"? True:false;
if (IE) {
if (Event.ctrlkey && window.event.keycode==13) {dosomething ();}
}else{
if (Iskeytrigger (e,13,true)) {dosomething ();}
}
}
function dosomething () {Document.frmTest.btn_insert.click ();}
============================= call only need to add in textarea onkeyup= "Web effects: Return Ctrlenter (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.