How can I trigger submit button thruough the Enter key in both Netscape and Internet Explorer?

Jasper Bos

This script works both in IE and NS because of the evt.which (IE) and evt.keyCode (NS) enjoy:

<SCRIPT LANGUAGE="JavaScript1.3">
//Enter-listener
if (document.layers)
  document.captureEvents(Event.KEYDOWN);
  document.onkeydown =
    function (evt) { 
      var keyCode = evt ? (evt.which ? evt.which : evt.keyCode) : event.keyCode;
      if (keyCode == 13)   //13 = the code for pressing ENTER
{ document.form.submit(); } } </SCRIPT>
0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact