火狐浏览器触发回车事件
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> <style type="text/css"> body, html {width: 100%;height: 100%;margin:0;font-family:"微软雅黑";} #allmap{width:100%;height:500px;} p{margin-left:5px; font-size:14px;} </style> <title>缩放地图</title> </head> <body onkeydown="keyLogin()"> <input id="huiche" onclick="huiche()" /> </body> </html> <script type="text/javascript"> function huiche(){ alert("huiche"); } function keyLogin(){ var theEvent = window.event || arguments.callee.caller.arguments[0]; //谷歌能识别event,火狐识别不了,所以增加了这一句,chrome浏览器可以直接支持event.keyCode var code = theEvent.keyCode; if(code == 13){ document.getElementById("huiche").click(); } } </script>