![]() |
|
![]() | ||
|
Subject:
Javascript function call
Category: Computers > Internet Asked by: ted2000-ga List Price: $5.00 |
Posted:
04 Jul 2006 14:12 PDT
Expires: 03 Aug 2006 14:12 PDT Question ID: 743341 |
One of my form in pure HTML has 1 text input field and 2 buttons. Pressing one of the buttons triggers a search-me() function. I'm also using the following script activated on a onkeydown event to ensure that the search-me function is also called when pressing ENTER after something in the input text field is entered. Everything should work exactly as if the user had pressed the button. Script used: function submitenter(e){ var keynum; if(window.event) { //IE keynum = e.keyCode;} else if(e.which){ // Netscape/Firefox/Opera keynum = e.which;} if (keynum == 13) { // 13 = value of ENTER key msg = 'Searching'; //NOTE1 alert(msg); //NOTE1 search-me();}} PROBLEM: - no problem with IE, including if I deactivate the lines that have NOTE1 at the end. - problem in Firefox 1.5.x if I deactivate the lines have NOTE1 at the end. The lines with NOTE1 at the end should not be used in the real world. I had those in the script for debugging purposes, showing a message + the value of the key pressed. But when I deactivate them, it no longer works in FF. Where is the bug? The search-me function includes a URL redirection such as window.location = searchurl. | |
|
![]() | ||
|
There is no answer at this time. |
![]() | ||
|
Subject:
Re: Javascript function call
From: crythias-ga on 11 Jul 2006 13:48 PDT |
Try this: function submitenter(e){ var keynum; if(window.event) { //IE keynum = window.event.keyCode;} else if(e){ // Netscape/Firefox/Opera keynum = e.which;} if (keynum == 13) { // 13 = value of ENTER key msg = 'Searching'; //NOTE1 alert(msg); //NOTE1 search-me();} } -=-=- onkeydown="submitenter(event)" |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
Search Google Answers for |
Google Home - Answers FAQ - Terms of Service - Privacy Policy |