View Full Version : Key Press in Mozilla

09-16-2005, 02:01 PM

I have a login page and in Internet Explorer when the user hits enter they get logged in. This doesn't work in Mozilla and the user has to click the login button instead. Can anyone see why this might be in this js code?

function entsub(_event, _ourform) {
alert("Login attempt: Highway");
if (_event && _event.keyCode == 13)
return true;


09-16-2005, 02:50 PM
Not without seeing how you catch the event.
My script catches the enter key (http://www.ipwebdesign.net/useful_keypress.html). See what's different between mine and yours.

09-16-2005, 03:14 PM
Mine is being called from a jsp page using:

<td class="TDLABEL-REQ">UserID:</td>
<td><input class="TEXT-REQ" type="text" onkeypress="return entsub(window.event,this.form)" size=15 name="userid" value=''> </td>
<td class="TDLABEL-REQ">Password:</td>
<td><input class="TEXT-REQ" type="password" onkeypress="return entsub(window.event,this.form)" size=15 name= "userpassword" value=''> </td>
<% if (session.getAttribute("login") !=null)
{ if (session.getAttribute("login").equals("fail")) { %>
<td class="TDLABEL-RED-LEFT">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Login Failed! Please Try again.
<% } else if (session.getAttribute("login").equals("not")) { %>
<td class="TDLABEL-RED">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Not Logged in! Please Login.
<% }
} else {%>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Please Login
<% } %>


Canuck WebGeek
09-16-2005, 03:28 PM
your passing in window.event as the first argument.

window.event is an IE only thing. In every other browser the event object is a "stand alone" thing that just gets passed to the trigger by the browser when it's fired.

do this instead

in the onkeypress trigger write :

return entsub(event,this.form)

and in the function do this:

function entsub(_event, _ourform) {
//grab IE's window.event if it exists
if (window.event) { _event = window.event; }