Page view counter

Keycode issue in firefox.

Last post 08-09-2007 3:18 AM by d4dennis@inspir3. 1 replies.

Sort Posts:

  • Keycode issue in firefox.

    08-09-2007, 2:21 AM
    • Loading...
    • sandesh
    • Joined on 11-28-2006, 12:30 PM
    • Delhi
    • Posts 20

    dear visitors, I am facing a problem in fire fox. I have to detect Enter key on body which working in IE. The code is below..

     

    function clickButton()
    {
       var bt = document.getElementById("<%=NextPrevious1.NextBtnClientID %>");
       if (bt)
          {
             
              var keycode;
              if (window.event)
                  keycode = window.event.keyCode;
              else if (e)
                  keycode = e.which;
              else
              return true;
                    if (keycode == 13)
                        {
                            bt.focus();
                            return false;
                        }
                
                else
                {
              
                    return true
                }
          }
    }

     

    This code is not working in Firefox. please help me..

     

    sandesh khare 

    sandesh
  • Re: Keycode issue in firefox.

    08-09-2007, 3:18 AM
    Answer

    Hi There,

    Try parse the event as following:

    <asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="clickButton(event);" />

    function clickButton(e)
    {
       var bt = document.getElementById("<%=NextPrevious1.NextBtnClientID %>");
       if (bt)
          {
             
              var keycode;
              if (window.event)
                  keycode = window.event.keyCode;
              else if (e)
                  keycode = e.which;
              else
              return true;
                    if (keycode == 13)
                        {
                            bt.focus();
                            return false;
                        }
                
                else
                {
              
                    return true
                }
          }
    }

    Hope it helps!

    DC517
    Don't forget to click "Mark as Answer" on the post that helped you.
    This credits that member, earns you a point and marks your thread as Resolved.
    Filed under: , ,
Page 1 of 1 (2 items)
Microsoft Communities