Reply
Enter Key not firing in Firefox
Old 05-17-2006, 01:35 AM Enter Key not firing in Firefox
Junior Talker

Posts: 1
Hi.

I have an .aspx page that I'm trying to get to fire some javascript code when I use the Enter key in a text box.

Here is my html/aspx code:

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


And this is the Javascript code it should fire:

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

As you can see, I have an alert box and that never appears.

Of course this all works just fine in IE, and that is my problem.

Any help would be greatly appreciated.

yd
yellowdog is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 05-17-2006, 01:48 AM Re: Enter Key not firing in Firefox
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
Converting Video For YouTube
Posts: 2,337
Name: Keith Marshall
Location: West Hartford, CT
I think you might be trying to make this harder than is necessary...

From what I know (and its not much) is when you are entering data in a form, pressing the enter key will automatically submit the form (in which you could execute a onSubmit event).
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 05-17-2006, 01:54 AM Re: Enter Key not firing in Firefox
vangogh's Avatar
Post Impressionist

Posts: 8,923
Name: Steven Bradley
Location: Boulder, Colorado
window.event is an IE only thing. I think you want something more like:

function myFunc(evt) {
evt = (evt) ? evt : ((window.event) ? window.event : "")
if (evt) {
// process event here
}
}

and in the html:

<input type="text" runat="server" id="tbSearch" onkeypress="javascript:SearchEnter(evt);">
__________________
l Search Engine Friendly Web Design | Van SEO Design
l Tips On Marketing, SEO, Design, and Development | TheVanBlog
l Custom WordPress Themes
| Small Business Forum

Last edited by vangogh : 05-17-2006 at 01:55 AM.
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Reply     « Reply to Enter Key not firing in Firefox
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.11562 seconds with 12 queries