Go Back  HTML Forums - Free Webmaster Forums and Help Forums > WEBSITE DEVELOPMENT > Client Side Scripting
User Name:
Password:
 

Reply
Thread Tools   Display Modes
  View First Unread
 
Old 03-06-2005, 02:26 AM
  #1
mitchell_1078
Novice (Level 1)
 
Join Date: Mar 2005
Posts: 10
iTrader: (0)
mitchell_1078 is on a distinguished road
Enter key event in Navigator

Dear all,

I am trying to get keyevent (enter key) in my script. Following function works in IE but doesnt work in Navigator. If anybody knows how to get it in Navigator, please help me! Any help would be much appreciated. Thanks in advance.

function submitenter(myfield,e)
{
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;

if (keycode == 13)
{
myfield.form.submit();
return false;
}
else return true;
}
mitchell_1078 is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 03-06-2005, 02:32 AM
  #2
_Aerospace_Eng_
The CSS Master (somewhat)
 
_Aerospace_Eng_'s Avatar
 
Join Date: Dec 2004
Location: In a galaxy far far away...
Posts: 11,154
iTrader: (0)
_Aerospace_Eng_ has disabled reputation
maybe u can try window.event.keyCode == 13 since keyCode is already a variable, you seem to be trying to declare it again
__________________

76 invites left. PM me for a Gmail invite along with email addy.
Why we won't help you .::. Web Developer's Handbook .::. Why Tables for Layout is Stupid?
_Aerospace_Eng_ is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 03-06-2005, 03:07 AM
  #3
mitchell_1078
Novice (Level 1)
 
Join Date: Mar 2005
Posts: 10
iTrader: (0)
mitchell_1078 is on a distinguished road
Thank you but it doesnt work. I have already tried it.
mitchell_1078 is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 03-06-2005, 07:21 AM
  #4
ElectricSheep
Myrmidon (Level 12)
 
Join Date: Jun 2004
Posts: 153
iTrader: (0)
ElectricSheep is on a distinguished road
This should work but we have not seen the rest of your code :

Stricter browsers need the event passed explicitly.

Change the first part of your function to this:

function submitenter(myfield,event)
{
var keycode;
if (event) keycode = event.keyCode;
else if (e) keycode = e.which;
else return true;

// leave the rest


Call the function like this:

submitenter('whatever',event)

For example :

<body onkeypress="submitenter('whatever',event)">

Also, I would advise you not to use the names of predefined properties as variable names.

Last edited by ElectricSheep : 03-06-2005 at 07:27 AM.
ElectricSheep is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote

Reply
KEEP TABS
SPONSORS
 
Boxedart
 
 


 
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
  
 
 
 



 
  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
Thread Tools
Display Modes

Forum Jump

 

All times are GMT -5. The time now is 08:10 AM.

   

Mascot team created by Drawshop.com

Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.

Server Monitoring by ENIACmonitor 0.01
HTMLforums.com © Big Resources, Inc. Web Design by BoxedArt.com
vRewrite 1.5 beta SEOed URLs completed by Tech Help Forum and Chalo Na.