Tuesday, November 1, 2011

calling body onload javascript in portlet jsr 168.

Since we are not calling body tag in jsp in jsr 168 portlet so simply create a script tag and call function as :-

<script>
function checkEnter()
{
document.body.onkeypress = enterKey
}
checkEnter();

</script>

Simply add this in your jsp and in check enter function you can call your own functions as I am calling enterKey Functions,
Here I am checking for the enter key press :
<script>
function enterKey(evt) {  
  var evt = (evt) ? evt : event;
  var charCode = (evt.which) ? evt.which : evt.keyCode;
  if (charCode == 13) {
    setOperationName('POST','RECEIPT');
    return false;
  }
  return true;
}
</script>

No comments:

Post a Comment