locked
code working in IE but not in mozilla RRS feed

  • Question

  • function clickButton($char, $mozChar)
         {
           if($mozChar != null)
           { // Look for a Mozilla-compatible browser
            if( $mozChar == 13 )
            {
               document.form1.bioInfoGoBtnId.click();
               return false;
            }
          }
          else
          { // Must be an IE-compatible Browser
           if($char==13)
           {
                document.form1.bioInfoGoBtnId.click();
                return false;
           }
          }
     
        }


    <div id="search_SearchTxt2" >
                        <input type="text" id="bioInfoSearchTxtId" onkeypress="return clickButton(event.keyCode, event.which)" />
      </div>
      
     <div id="search_SearchGo"   >
                        <a tabindex="1" ><img id="bioInfoGoBtnId" src="Images/go.gif"  onclick='searchtext(1);' /></a>
      </div>

      Above code is working fine in IE but not in mozilla. Please replay me with appropriate replacement. Its urgent.
      Thanks in advance.
    Tuesday, March 25, 2008 9:12 AM

All replies

  •  

    Mozilla doesn't provide a global event object.

     

    Use:-

     

    Code Snippet

    function clickButton(ev)

    {

    var charCode =  ev ? ev.which : event.keyCode;

    if (charCode == 13)

    {

    document.getElementById("bioInfoGoBtnId").click();

    return false;

    }

     

     

    The onkeypress property looks like:-

     

    Code Snippet

    onkeypress="return clickButton.apply(this, arguments)"

     

     

    Tuesday, March 25, 2008 11:06 AM


  • Thanks for your replay but click() event have not raised in mozilla please post me if there is  any another code that meets this requirement.
    Actually requirement is I have a search box  and a go button beside that. After entering text into the text box generally users press enter  instead of go  button. Please send me the client side code that meets requirement. Thanks.

     
    Wednesday, March 26, 2008 4:54 AM
  • I've tested the following in IE7 and FF2 works fine:-

     

    Code Snippet

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">

    <head id="Head1" runat="server">

    <title>Simple Test</title>

    <style type="text/css">

    </style>

    <script type="text/javascript">

    function clickButton(ev)

    {

    var charCode = ev ? ev.which : event.keyCode;

    if (charCode == 13)

    {

    document.getElementById("cmd").click();

    return false;

    }

    }

    </script>

    </head>

    <body>

    <form id="form2" runat="server">

    <input type="text" id="txt" name="txt" onkeypress="return clickButton.apply(this, arguments)" />

    <input type="button" id="cmd" onclick="alert('click')" />

    </form>

    </body>

    </html>

     

     

     

    Wednesday, March 26, 2008 2:04 PM

  • I have developed some webusercontrols and converted them into dlls.
    I reused the dlls in other project and i recognised that the functionality is working in IE but not in Mozilla.

    I am just wondering about this issue.
    what might be the problem here, any suggestions?????????
    Thursday, April 24, 2008 4:49 AM
  •  

    If you have compiled components working in IE but not in mozilla then I think you probably need to ask the question in one of mozillas NGs :-  news:mozilla.org 

     

     

    Thursday, April 24, 2008 9:11 AM
  • I have also tested it works fine in IE but not work in-Firefox 3.6 .
    what should i do?please help me its very urgent.
    Thursday, February 4, 2010 11:01 AM