+ -
当前位置:首页 → 问答吧 → window.onkeypress

window.onkeypress

时间:2011-11-28

来源:互联网

funcation OnSel(){
 alert("a");

window.onkeypress = function () {

  if (event.keyCode == 13) {

  OnSel();

  event.returnValue = false;

  }
 

为什么不能兼容。ie6-8,只有ie9有用??急。在线等

作者: wangbaolei520   发布时间: 2011-11-28

$(function() {
   
document.onkeypress = function() { //监视处理文档对象的键盘事件
if (typeof(event) != "undefined") {
if (event.keyCode == 13) { //13为回车的键码
OnSel();

return false;
}
}
}
});

作者: programmerxiaocai   发布时间: 2011-11-28

$(function() {
   
document.onkeypress = function() { //监视处理文档对象的键盘事件
if (typeof(event) != "undefined") {
if (event.keyCode == 13) { //13为回车的键码
OnSel();

return false;
}
}
}
});

作者: programmerxiaocai   发布时间: 2011-11-28

document.onkeypress吧

作者: ifandui   发布时间: 2011-11-28

我不会大蛇啊,据说很牛逼

作者: frustrate2   发布时间: 2011-11-28

引用楼主 wangbaolei520 的回复:
funcation OnSel(){
alert("a");
}
window.onkeypress = function () {

if (event.keyCode == 13) {

OnSel();

event.returnValue = false;

}

}
为什么不能兼容。ie6-8,只有ie9……

那 我写的代码哪里有问题吗?

作者: wangbaolei520   发布时间: 2011-11-28

document.onkeypress
not 
window.onkeypress

作者: ifandui   发布时间: 2011-11-28

相关阅读 更多

热门下载

更多