Jump to content

Recommended Posts

Posted

por javascript B)

document.onkeydown = function() {

      if( !e ) {

    if( window.event ) {

    //Internet Explorer

      e = window.event;

    } else {

      return;

    }

  }

  if( typeof( e.keyCode ) == 'number'  ) {

    //DOM

      e = e.keyCode;

  } else if( typeof( e.which ) == 'number' ) {

    //NS 4 compatible

      e = e.which;

  } else if( typeof( e.charCode ) == 'number'  ) {

    //also NS 6+, Mozilla 0.9+

      e = e.charCode;

  } else {

    //total failure, we have no way of obtaining the key code

    return;

  }

  if(e==13) {

    document.getElementById('btnSubmit').click();

  }

};

There are two ways to write error-free programs; only the third one works.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.