0

我正在尝试使用 TAB 按钮提交表单。

它适用于 FF、IE8,但在 IE9 上我无法停止默认操作。

我在这里找到了答案:How do I convert Enter to Tab (with focus change) in IE9? 它在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;
}
4

1 回答 1

1

问题是在 IE 中 onkeypress 不返回 ctrl、shift 或 tab 的键码,onkeydown 成功了。

于 2011-08-09T12:45:33.843 回答