简体   繁体   English

我的JavaScript代码在Firefox中运行良好,但在Chrome和IE中却没有

[英]My JavaScript code works fine in Firefox, but not in chrome and IE

JavaScript code : common.js JavaScript代码common.js

function setFocus(evt,data)
{
  var keycode=evt.keyCode;  
  $("[tabindex="+data[keycode]+"]").focus();
  return false; 
}

PHP code : PHP代码

<table class="tblmenu">
   <tr>
      <td><div class="redbut"><a href="#" id="formstng"    tabindex="1" onKeyPress="setFocus(event,{'38':'5','40':'2'})">foT Aosa.Aona.Aof. laokTao saoTIMga </a></div></li></td>
   </tr>
   <tr>
      <td><div class="redbut"><a href="#" id="setting" tabindex="2" onKeyPress="setFocus(event,{'38':'1','40':'3'})">roT saoTIMga</a></div></td>
   </tr>
   <tr>
      <td><div class="redbut"><a href="#" tabindex="3" onKeyPress="setFocus(event,{'38':'2','40':'4'})">slaIpa saoTIMga</a></div></td>
   </tr>
   <tr>
      <td><div class="redbut"><a href="#" tabindex="4" onKeyPress="setFocus(event,{'38':'3','40':'5'})">isasTma saoTIMga</a></div></td>
   </tr>
   <tr>
      <td><div class="redbut"><a href="#"  tabindex="5" onKeyPress="setFocus(event,{'38':'4','40':'1'})">yauzr AonT/I</a></div></td>
   </tr>
</table>

i have try to focus on link with arrow key.this is worked fine in firefox but not in chrome and IE. 我试着把重点放在箭头键的链接上。这在firefox中工作得很好但在chrome和IE中却没有。 Thanks in Advance.. 提前致谢..

请使用evt.charCode而不是evt.keyCode for IE,(即)你可以使用如下,

  var keycode =  evt.keyCode? evt.keyCode : evt.charCode

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 此代码可以在ie 10上正常运行,但不能在chrome和firefox上运行(javascript / ajax部分) - this code works fine on ie 10 but not on chrome and firefox (javascript/ajax portion) JavaScript函数不适用于Chrome和IE,但适用于FireFox - JavaScript function not working on Chrome & IE but works on FireFox RSS不会在IE和chrome上显示,但在Firefox上能正常显示吗? - RSS won't show on IE and chrome but works fine on Firefox? 该网站在IE上显示黑屏,但在Firefox或chrome中可以正常工作 - site shows blank screen on IE but works fine in firefox or chrome Ajax 调用/javascript - 在 IE、Firefox 和 Safari 上运行良好,但在 Chrome 上运行不正常 - Ajax call/javascript - working fine on IE, Firefox and Safari but not on Chrome PHP和JavaScript-“注销”代码在Chrome中有效,但在Firefox中不可用 - PHP and JavaScript - “Logout” code works in Chrome, but not in Firefox IE MP3流。 在Firefox中可以正常工作,但在IE和Chrome中则不能。 标头问题 - IE MP3 Streaming. Works fine in Firefox but not in IE and Chrome. Header problems JavaScript时钟可在Chrome上使用,但不适用于Firefox或IE - JavaScript clock works on Chrome but doesn't work with Firefox or IE Javascript / Ajax可在Mozilla firefox中使用,但不能在Google Chrome和IE中使用 - Javascript / Ajax works in Mozilla firefox but not in Google Chrome and IE 查询适用于Firefox,但不适用于ie和chrome - query works on firefox but not on ie and chrome
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM