2011-07-21 154 views
0

我想使表单提交与选项卡按钮。IE9控制键盘按钮

它正在使用FF,IE8,但在IE9上,我无法停止默认操作。

我在这里找到了答案:How do I convert Enter to Tab (with focus change) in IE9? It worked in IE8

但我不能执行它。

有人可以解释为ie9“修复”我应该添加我的脚本工作。

谢谢

function checkcode(e) { 
    var keycode; 
    if(!e) 
     e = window.event; 
    if(e.keyCode) 
     keycode = e.keyCode; 
    else 
     keycode = e.charCode; 
    if(keycode == 9 || keycode == 13) { 
     e.preventDefault();   //Problem is here 
     alert(keycode); 
     return false; 
    } else return true; 
} 
+0

有人吗?这对每个人都有用:) – Simba

+0

我试过使用:e.cancelBubble = true; e.stopPropagation();如果(e.preventDefault){e.preventDefault() }其他{ e.returnValue = false alert('prevent'); }但这不起作用。我在想事件前处理TAB按钮。任何帮助,将不胜感激。 – Simba

回答

1

的问题是,在IE onkeypress事件不会对Ctrl,Shift或标签返回键代码,做的onkeydown的伎俩。