jQuery replacement for Default Button or Link

Posted by pyccki on Stack Overflow See other posts from Stack Overflow or by pyccki
Published on 2009-06-30T16:07:12Z Indexed on 2010/06/01 8:03 UTC
Read the original article Hit count: 146

Filed under:
|
|

As everyone knows, that default button doesn't work in FF, only IE. I've tried to put in the tag or in the and it's not working. I've found a js script to fix this issue, but for some reason it's not working for me. This script for a submit button, i need to use it for a LinkButton, which is should be the same.

Link:

  <div id="pnl">
    <a id="ctl00_cphMain_lbLogin" title="Click Here to LogIn" href="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;ctl00$cphMain$lbLogin&quot;, &quot;&quot;, true, &quot;Login1&quot;, &quot;&quot;, false, true))">Log In</a>
    <input name="ctl00$cphMain$UserName" type="text" id="ctl00_cphMain_UserName" />
    <input name="ctl00$cphMain$UserName" type="text" id="ctl00_cphMain_UserName1" />
  </div>

<script>

 $(document).ready(function() {
    $("#pnl").keypress(function(e) {
        if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) {
            $("a[id$='_lbLogin']").click();
            return true;
        }
    });
});

I know that i can override original function "*WebForm_FireDefaultButton*" in This post, but i really wanted to get this one to work.

Thanx in advance!!!

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about jQuery