监听enter事件
document.onkeydown=keyDownSearch;
function keyDownSearch(e) {
// 兼容FF和IE和Opera
var theEvent = e || window.event;
var code = theEvent.keyCode || theEvent.which || theEvent.charCode;
if (code == 13) {
alert('回车');//具体处理函数
return false;
}
return true;
}
</script>
如果只是针对某个DIV层应用回车查询的话,可以将:
document.onkeydown=keyDownSearch; 改成:
document.getElementById('层ID').onkeydown=keyDownSearch;