JS监听整个页面的回车事件
<script type="text/javascript">
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) {
getTableListData();//具体处理函数
return false;
}
return true;
}
</script>
如果只是针对某个DIV层应用回车查询的话,可以将:
document.onkeydown=keyDownSearch;
改成:
document.getElementById('层ID').onkeydown=keyDownSearch;