首页 > 其他 > 详细

input框触发回车事件

时间:2016-08-26 09:09:33      阅读:326      评论:0      收藏:0      [点我收藏+]

window.event只能在IE下运行,不能在firefox下运行,这是因为firefox的event只能在事件发生的现场使用。   
在firefox里直接调用event对象会报undefined。
兼容解决方式:

 1 <input type="text" onkeydown="keyup_submit(event);">
 2 
 3 <script>
 4 function keyup_submit(e){ 
 5  var evt = window.event || e; 
 6   if (evt.keyCode == 13){
 7     //回车事件
 8   }
 9 }
10 </script>

 



*firefox需要传递event对象,书写必须为event

input框触发回车事件

原文:http://www.cnblogs.com/houweijian/p/5808978.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!