Enter Key on Netscape.

  • Thread starter Thread starter Stephen
  • Start date Start date
S

Stephen

Hi,

I have made use of javascript to make use of enter key, I hit "enter" and
the button fires....this piece of code works only for IE and not for
Netscape. In Netscape, I have to click the button.


the code is:

function doLogin()
{
if ((event.which && event.which == 13) || (event.keyCode &&
event.keyCode == 13))
{
document.all("btnLogin").click();return false;
}
else
{
return true;
}
}

<form id="Form1" method="post" runat="server">
<table width="500" align="center">
<tr>
<td><INPUT id="txtLogin" type="text" name="txtPost" runat="server"
onkeydown="doLogin()"></td>
<td><INPUT id="btnLogin" type="button" value="Login" name="btnPost"
runat="server"></td>
</tr>
</table>
</form>

private void btnLogin_ServerClick(object sender, System.EventArgs e)
{
Response.Write("<br>Login is fired at: " +
DateTime.Now.ToLongTimeString());
}



please advice,
Stephen
 
netscape (at least the moxzilla based versions) uses the w3c dom and events.
while you got the event handling close, there is no document.all in any
browser except IE. also i don't believe there is a global event in other
browser, you should use window.event

to find an element use

document.getElementById(idName)
 
Back
Top