回車鍵兼容ff的處理-event問題

document.οnkeydοwn=function(){
if (event.keyCode == 13){...}
}
或
var username=document.getElementById('usr');
username.οnkeydοwn=function(){
if (event.keyCode == 13){document.getElementById('loginbtn').focus();...}
}

兼容ff的代碼:

標準的事件模型裏,dispatch事件時,第一個參數就是event;不像IE,自己弄了個全局的event.所以說這裏其實是要兼容ie,而不是兼容ff。但後來發現chrome做了和ie一樣的事情。。。。無語。

e就是ondeydown事件。

document.οnkeydοwn=function (e){
e = e || event;
if(e.keyCode==13){
document.getElementById('btnLogin').focus();
}
}

發佈了31 篇原創文章 · 獲贊 5 · 訪問量 17萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章