+ Start a Discussion
Naresh Krishna.ax1176Naresh Krishna.ax1176 

Enter key not working in IE8

Hi all,

 

<c:EnterButton/>

<apex:commandButton action="{!searchFor}" accesskey="enter" value="search" />

 

Below is the EnterButton component used:-

 

<apex:component selfClosing="true">
  <script type="text/javascript">
    function replaceEnter(e){
      if (e.keyCode == 13){
        var allElements = document.getElementsByTagName('*');
        for (var i = 0; i < allElements.length; i++){
          if (allElements[i].id.indexOf("ENTER_BUTTON") !=-1){
            allElements[i].click();
          }
        }
        return false;
      }else{
        return true;
      }
    }
    window.onkeypress = replaceEnter;
  </script>
</apex:component> 

 

when I pressed on enter key in IE8 browser, nothing was done and the page simply refreshed.

 

Can anyone help me with fixing this issue ?

 

Thanks.

 

 

 

SeAlVaSeAlVa

Try

<apex:commandButton action="{!searchFor}" accesskey="enter" value="search" id="ENTER_BUTTON" />

 

It is in the blog I'm creating by the way. :P

The following component allows you to do that. You just have to use the component below and set to ‘ENTER_BUTTON’ the ID of the button to be triggered and include the componen in your Visual Force Page.

 

Naresh Krishna.ax1176Naresh Krishna.ax1176

tried by giving ID to component but it also not worked.

 

could you please suggest any other.

SeAlVaSeAlVa

you don't need to provide the ID to the component, what you need is to provide the ID to the commandButton you want to call.

 

ID should be ENTER_BUTTON

 

Regards