简体   繁体   中英

Try to prevent reload page when hit enter in input type text in old version of Internet Explorer

Need your help friends

I made a functions o prevent reload page when hit enter in input type text in old version of Internet Explorer. it is working in new version of Internet Explorer but in the old version (Below 8) This code doesnt work. I use this browser to programm this because i this page will be displayed in a barcode scanner machine (a portable console) which is old version of internet explorer browser was installed.

here's the code HTML and Javascript:

<td align='left'><input type='text' size='15' name='packing_to_id' id='packing_to_id' size='10' value='' onkeypress="return InputKeyPress(event)"></td>

<script type="text/javascript">
function InputKeyPress(e){

  e=e||window.event;
  var key = e.keyCode;
  if(key==13) 
  {

     return false; 
  }
}
</script>

Use event.returnValue = false;

Sample Code:

<script type="text/javascript">
function InputKeyPress(e){

  e=e||window.event;
  var key = e.keyCode;
  if(key==13) 
  {
     e.returnValue = false;
     return false; 
  }
}
</script>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM