473,406 Members | 2,710 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.

Enter Key not firing in Firefox

Hi.

I have an .aspx page that I'm trying to get to fire some Javascript on an Enter Key press inside a text box in a Firefox browser.

Here is the .aspx/html code:

<input type="text" runat="server" id="tbSearch" onkeypress="javascript:SearchEnter();">

And here is the java it's trying to fire:

function SearchEnter()
{

if ( (window.event && window.event.keyCode == 13) || (window.event.charCode == 13))
{
alert("SearchEnter");
SubmitSearch();
}
}

The alert message never appears.

Of course this works fine in IE, just not Firefox.

Any help would be greatly appreciated.

yd
May 17 '06 #1
4 11758
Banfa
9,065 Expert Mod 8TB
window.event (the event member of the window object) does not exist in Firefox (or any Mozilla implementation).

Unfortunately while a lot of things to do with web standards and programming have been standardised events are not one of them .

If order to capture both the Mozilla and IE event objects I think you need to change your SearchEnter function like so

Expand|Select|Wrap|Line Numbers
  1. function SerachEnter(e)
  2. {
  3.     if (!e) var e = window.event
  4.     // e refers to the event
  5.  
  6.     /* Rest of code here */
  7. }
  8.  
you may also need to change your html to

[html]
<input type="text" runat="server" id="tbSearch" onkeypress="SearchEnter(event);">
[/html]
May 17 '06 #2
use e.which rathre than e.keyCode this will solve your problem :)
Feb 9 '07 #3
dmjpro
2,476 2GB
if window.event does not support use window.evt
Feb 9 '07 #4
acoder
16,027 Expert Mod 8TB
Syed is right, for browsers which do not support keyCode, use e.which.

For information on events and browser compatibility, see the following links:
http://www.quirksmode.org/js/events_properties.html
http://www.quirksmode.org/dom/w3c_events.html
Feb 9 '07 #5

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

Similar topics

4
by: realraven2000 | last post by:
Hi, my colleague coded the following onclick events with Javascript which only seem to fire in IE not in firefox. The checkboxes are built in Form frmProdDet while looping through a recordset...
1
by: mdipiet | last post by:
I've got a form that is supposed to validate data entry from a bar code scanner. The scanner is set up to add a carriage return at the end of the data in the barcode, which should fire the...
5
by: John Abbler | last post by:
I'm currently testing doing some testing with other browsers and have found that my custom field validators aren't firing with Firefox or Netscape, but they work fine with Ie. Here's the code...
5
by: Datagridtextboxcolumn not firing event | last post by:
"PLEASE HELP, I NEED HELP N O W !!!" AddHandler dgtxtboxcolumn.textbox.KeyDown, AddressOf TextBoxKeyPress Private Sub TextBoxKeyPress(ByVal sender as Object, ByVal e as KeyEventArgs) End...
0
by: Tom Edelbrok | last post by:
I'm using VS 2005 to develop an intranet asp.net web application and I get a weird situation. If I start out with any ASPX page that contains an ImageButton control followed by a TextBox control,...
4
by: nkoier | last post by:
Hi, I've been going crazy trying to figure out what's wrong with our Asp.Net 2.0 intranet site. At the very top of our main page I provide a TextBox and a Button for submitting Google searches....
1
by: =?Utf-8?B?Sm9zZW1h?= | last post by:
Hi, I have a form runat server with two asp:textbox and one asp:imagebutton Im trying to debug a problem when the user clicks in the imagebutton but the event its not firing in firefox. I...
0
by: Ganesh | last post by:
gridview row command event is not firing in Mozilla , asp.net 2.0 need to select a row and store the hidden value of that prticlar row in session working fine in IE
9
Basharat
by: Basharat | last post by:
Hi all I have problem on firing "onmouseleave" event of <div> html element. Here is the code im using: <div ID="BSHelpPanel" class="PageMenuMain" onclick="javascript:this.style.display='none';"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
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.