Enter Key on Netscape.

Discussion in 'ASP .Net' started by Stephen, Sep 22, 2004.

  1. Stephen

    Stephen Guest

    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
     
    Stephen, Sep 22, 2004
    #1
    1. Advertising

  2. Stephen

    bruce barker Guest

    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" <> wrote in message
    news:...
    > 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
    >
    >
     
    bruce barker, Sep 23, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stephen

    Netscape + enter key Problem

    Stephen, Aug 20, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    393
    Stephen
    Aug 20, 2004
  2. BrianDH

    Enter Key H*ll, control enter key submit button

    BrianDH, Jan 12, 2005, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    403
    Anders Matthiessen
    Jan 12, 2005
  3. M P
    Replies:
    1
    Views:
    483
  4. Matt
    Replies:
    1
    Views:
    510
    Michael Winter
    Mar 6, 2004
  5. HopfZ
    Replies:
    0
    Views:
    576
    HopfZ
    Aug 28, 2006
Loading...

Share This Page