Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Enter Key on Netscape.

Reply
Thread Tools

Enter Key on Netscape.

 
 
Stephen
Guest
Posts: n/a
 
      09-22-2004
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


 
Reply With Quote
 
 
 
 
bruce barker
Guest
Posts: n/a
 
      09-22-2004
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)



"Stephen" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
File Upload - Change key code for ENTER key on Browse Button bsm ASP .Net 0 05-10-2007 11:13 AM
capturing from text area Shft+Enter, Control+Enter, Alt+Enter and browser issue. HopfZ Javascript 0 08-28-2006 10:11 AM
Enter Key H*ll, control enter key submit button BrianDH ASP .Net Web Controls 3 01-12-2005 08:29 PM
Replace Tab Key to Return Key (Enter Key) from Web Forms? M P ASP General 1 08-06-2004 08:32 AM
trigger HTML button by enter ENTER key Matt Javascript 1 03-06-2004 07:01 PM



Advertisments