473,406 Members | 2,633 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

keypress not working in FireFox

Claus Mygind
571 512MB
In the code below, the following will prevent the keypress or keydown event from firing. And I just wondering why.

1. If when the form is loaded the button is disabled.
2. The button is set active when a change occurs on the text box.
3. The button will not fire on the keypress event.

However, if the button is not disabled when the form is loaded then the event will fire. Why?

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3.  <head>
  4.   <title>Key Prss Test</title>
  5.   <script type="text/javascript">
  6.   <!--
  7.         function main()
  8.         {
  9.             this.assignEventListners = function (obj)
  10.             {
  11.                 var thisText = document.getElementById('thisText');
  12.                 if (thisText.addEventListener)
  13.                 {
  14.                     thisText.addEventListener('change', 
  15.                         function(evt)
  16.                         {
  17.                                     document.getElementById("sbRun").disabled = false;
  18. //                                    document.getElementById("sbRun").select();
  19. //                                    document.getElementById("sbRun").focus();
  20.                         },
  21.                         false)
  22.                 }
  23.                 var sbRun = document.getElementById('sbRun');
  24.                 if (sbRun.addEventListener)
  25.                 {
  26.                     sbRun.addEventListener('keydown', m.runReport, false);
  27.                 }
  28. /*
  29.                 var sbRun2 = document.getElementById('sbRun2');
  30.                 if (sbRun2.addEventListener)
  31.                 {
  32.                     sbRun2.addEventListener('keydown', m.runReport, false);
  33.                 }
  34. */
  35.             };
  36.  
  37.             this.runReport = function ()
  38.             {
  39.                 alert(document.getElementById("thisText").value);
  40.             };
  41.  
  42.         }
  43.         m = new main;
  44.  
  45.   //-->
  46.   </script>
  47.  </head>
  48.  
  49.  <body id="testKeyPress" onload="m.assignEventListners(this);">
  50.     <form method="post" action="" onSubmit="return false;">
  51.         <input type="text" id="thisText">
  52.         <input type="button" id="sbRun" value="Go1" disabled>
  53.         <!-- <input type="button" id="sbRun2" value="Go2"> -->
  54.     </form>
  55.  </body>
  56. </html>
  57.  
  58.  
May 5 '14 #1

✓ answered by Dormilich

late replay, ...

However, if the button is not disabled when the form is loaded then the event will fire.
I couldn’t verify this. In every variation I tried it didn’t fire a keydown event (hitting enter didn’t trigger anything and a mouse click certainly doesn’t fire a key event)

2 2267
Dormilich
8,658 Expert Mod 8TB
late replay, ...

However, if the button is not disabled when the form is loaded then the event will fire.
I couldn’t verify this. In every variation I tried it didn’t fire a keydown event (hitting enter didn’t trigger anything and a mouse click certainly doesn’t fire a key event)
May 21 '14 #2
Claus Mygind
571 512MB
Thanks for confirming that the button event would not fire, when the initial state is disabled.
May 23 '14 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: sonic_soul | last post by:
Hi, I was curious if I could make my webservice work with firefox client webservice functionality. (i got it to work with webservice.htc) I am able to get firefox to see my serverside web...
3
by: coolsti | last post by:
Can someone help me enhance this code snippet which works only for IE so that it will also work for Firefox? I have been trying all sorts of things and have gotten to where I can capture the...
6
by: rich_poppleton | last post by:
Help.... I've got a textarea where people type in a description. However for certain reasons we need to stop them typing !$*^ . I have a solution this which works fine in IE: function...
3
by: Darryn Ross | last post by:
Hi, I am trying to catch the KeyPress event on my datagrid but it isn't working... i have also tried registering the handler with the event like this... dgGLBatch.KeyPress += new...
3
by: TJS | last post by:
I am finding that the serverside requiredvalidator doesn't fire in the firefox browser, and user request proceeds through to my updateProfile method. Validation is working correctly in the IE...
15
by: Adam J. Schaff | last post by:
I have noticed that if a user closes a form via pressing return (either while the OK button has focus or if AcceptButton is set to OK for the form) then the "ENTER" keypress event fires ON THE...
4
by: Jeff | last post by:
....still new at this. ...hopefully a simple question Is there some practical way of altering the function of a keypress in Visual Web.net 2005 using VB without causing a postback on each...
4
by: Dave (DreamIsle) | last post by:
I can't figure out why my keypress script is not working. I used the following code: document.onkeypress = KeyCheck; function KeyCheck(e) { var KeyID = (window.event) ? event.keyCode :...
3
by: geetha v | last post by:
Hi All, I need a scrolling DIV is a to display my dynamic tree in left frame. In my jsp , Div overflow is set to "auto" <DIV id=divScroller style="overflow:auto;height:200px"> <!--...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.