Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Mar 2008
    Posts
    34
    Thanks
    6
    Thanked 0 Times in 0 Posts

    make ENTER key click a button on page

    I have this working in IE with the code below, but it does nothing in Firefox (and Safari, Opera). Basically if a user clicks the enter key at ANY time, I want the "NEXT" button to be clicked.

    Code:
    function fnTrapKeyDown(e)
    {
    	if (document.all)
    	{
    		if (event.keyCode == 13)
    		{
    			event.returnValue=false;
    			event.cancel = true;
    
    			document.getElementById("NEXT").click();
    		}
    	}
    }
    Please help me in adapting this for Firefox (and possibly the other two browsers), because I'm stuck.
    Last edited by brookey86; 05-07-2008 at 06:41 PM.

  • #2
    New Coder
    Join Date
    Mar 2008
    Posts
    34
    Thanks
    6
    Thanked 0 Times in 0 Posts
    oh also, i have this to call the code above:

    Code:
    document.body.onkeydown=function(){
    
    	fnTrapKeyDown(event);


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •