Link to home
Start Free TrialLog in
Avatar of WaldaInc
WaldaInc

asked on

Enter key not firing in Firefox

Hi.

I have a textbox that I am trying to get to fire (run some javascript code) in Firefox. The code works just fine in IE, but it doesn't in ie.

This is where I stand right now.

Here how I defined my text box

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

The onblur and onkeydown will not fire the javascript. I have an alert box in the js and it never displays.  If I click on an image control (that has java attached) that will fire, but not the Enter key.

My java code looks like this:

function SearchEnter()
{

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


Any help with this would be greatly appreciated.
Avatar of Sammy
Sammy
Flag of Canada image

take a look here for a solution and why it doesnt work in ff
http://www.webmaster-talk.com/javascript-forum/40661-javascript-works-ie-but-not-firefox.html

good luck
Avatar of WaldaInc
WaldaInc

ASKER

Nope.

That still wouldn't fire my function.  

Any other ideas??
I just spent sometime reading on fire fox handling of event since I know window.event is IE specific
I found something the author claims it worked for him.
It is a fairly long script.
http://groups.google.ca/group/comp.lang.javascript/browse_thread/thread/f5cb196ed8e299fc/5b3e8bd80dc55eaf?lnk=st&q=capture+enter+key+in+firefox&rnum=1&hl=en#5b3e8bd80dc55eaf

Good luck
All you need to do is use the panel with a default button tag. That is intended for this purpose so example

<asp:panel defaultbutton="Button1" runat="server">
        <h3>Search Discount Beauty Shop Products</h3>
        <asp:Label ID="Label1" runat="server" Text="Search"></asp:Label>
        <asp:TextBox ID="TextBox1" CssClass="textbox" runat="server"></asp:TextBox>
        <asp:Button ID="Button1" runat="server" Text="Search" CssClass="submitbutton" OnClick="SubmitSearch"/>
</asp:panel>
Hi,

Do you require further assistance with this?

Andrew
Sorry for not responding sooner, I've been swamped at work.

This is the URL where I found the answer.  

http://www.webmaster-talk.com/javascript-forum/51214-enter-key-not-firing-in-firefox.html#post242639

Thanks for everyone's help on this issue.

yd
ASKER CERTIFIED SOLUTION
Avatar of GranMod
GranMod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial