Enter Key on Netscape.

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
 
B

bruce barker

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top