•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 455,974 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,807 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 4017 | Replies: 1
![]() |
| |
•
•
Join Date: Oct 2007
Posts: 8
Reputation:
Rep Power: 0
Solved Threads: 0
Hi All,
I'm having problem with the onkeypress attribute, I'm not sure if my code is right. When pressing the enter button, the javascript function would work on IE but not in Firefox. I'm not sure if the event keyCode is being recognized by Firefox or if I'm missing something...
Here's a code snippet of my code:
<td width="270px"><input type="text" id="searchB" value="" style ="font-family:Verdana; font-size:10pt; width: 270px; height:100% ;" onkeypress="enterHere();" onFocus="this.select();" ></td>
<script language="javascript" type="text/javascript">
function enterHere()
{
if((event.which && event.which == 13) || (event.keyCode && event.keyCode == 13))
{
find();
}
}
</script>
Can anyone help me on this...????
Thanks...
I'm having problem with the onkeypress attribute, I'm not sure if my code is right. When pressing the enter button, the javascript function would work on IE but not in Firefox. I'm not sure if the event keyCode is being recognized by Firefox or if I'm missing something...
Here's a code snippet of my code:
<td width="270px"><input type="text" id="searchB" value="" style ="font-family:Verdana; font-size:10pt; width: 270px; height:100% ;" onkeypress="enterHere();" onFocus="this.select();" ></td>
<script language="javascript" type="text/javascript">
function enterHere()
{
if((event.which && event.which == 13) || (event.keyCode && event.keyCode == 13))
{
find();
}
}
</script>
Can anyone help me on this...????
Thanks...
>When pressing the enter button, the javascript function would work on IE but not in Firefox.
This is because, in Firefox, the event is passed as a parameter to the event handler.
This is because, in Firefox, the event is passed as a parameter to the event handler.
event property of the window object is IE only. javascript Syntax (Toggle Plain Text)
function enterHere(e) { e = e || window.event; var code = e.keyCode || e.which; if(code == 13) find(); }
Last edited by ~s.o.s~ : Nov 28th, 2007 at 12:49 pm.
I don't accept change. I don't deserve to live.
Happiness corrupts people.
Failing to value the lives of others cheapens your own.
Happiness corrupts people.
Failing to value the lives of others cheapens your own.
![]() |
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
addiction ajax asp beta blackberry bon browser browsers browsing developer development echo email encryption europe firefox gecko home html internet internet explorer javascript leak linux memory microsoft mozilla msdn networking news office open source open-source patch phishing scams security site social software sql super survey teleworking testing users vista web webmail work
- Previous Thread: Frame Usage
- Next Thread: alert dialog box



Hybrid Mode