js兼容firefox和ie的ctrl+enter事件捕获
来源:互联网 发布:腾讯 大数据事业部 编辑:程序博客网 时间:2024/05/18 00:00
想用JavaScript写个捕获ctrl+enter事件的函数,原本是简单的判断event.ctrlKey&&按键的keycode为13就可以了,却发现该函数在firefox下可以用用,在ie下却挂了,最后查找ie下的ctrl+enter应该判断按键码为10.例子如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Js Ctrl And Enter Event Caputure</title>
<style>
*{margin:0;padding:0;line-height:18px;}
</style>
</head>
<body>
<div id="display"style="margin:40px auto;width:400px;height:200px;">
</div>
<div style="margin:0 auto;width:400px;text-align:center;">
<textarea onkeypress="capture(event,this)"style="width:400px;height:200px;line-height:18px;"></textarea>
<div>
</body>
</html>
<script language='javascript'>
window.$= function(id){returndocument.getElementById(id);}
function capture(event,o)
{
var keynum;
if(window.event)
{
keynum=event.keyCode;
}
else
{
keynum=event.which;
}
event= event || window.event;
if(event.ctrlKey&&(keynum==13||keynum==10))
{
$('display').innerHTML += '<p>'+ o.value + '</p>';
o.value='';
}
}
</script>
- js兼容firefox和ie的ctrl+enter事件捕获
- 接受ctrl+enter事件,兼容FF和IE
- 兼容ie和 firefox的event事件
- js脚本:ie和firefox的兼容
- js捕获键盘事件firefox和ie有区别
- js键盘事件全面控制 兼容FireFox和IE
- js键盘事件全面控制 兼容FireFox和IE
- js键盘事件全面控制 兼容FireFox和IE
- [js] 兼容IE和firefox
- JS触发ctrl+enter的事件
- js、jQuery,兼容IE与firefox火狐的回车事件
- IE、firefox的js兼容
- FF和IE兼容的捕获回车事件问题
- IE和Firefox完全兼容的Tab代替Enter的Javascript代码
- IE、Chrome兼容Enter事件
- 书写同时兼容IE和FireFox的事件处理代码
- 兼容Firefox和IE的onpropertychange事件oninput
- 兼容Firefox和IE的onpropertychange事件oninput
- DVT和ADVT - 为数不多的DICOM测试工具说明AND下载
- 测试自动化框架之----自定义报表与错误处理两个模块视频
- 数据库三层架构
- Hibernate学习 笔记(一)
- .net 二次开发AutoCad的调试
- js兼容firefox和ie的ctrl+enter事件捕获
- OllyDbg超简明手册
- www.5173rt.com百度快照降到5月7日处理办法
- [下载]《Windows 7 Beta 产品指南》中英文版原版
- LINQ又被赋予了新的Active?
- 在Windows下使用gcc
- 怎样处理Svchost.exe Application Error错误
- 又回来了
- 查韦斯赞国产手机:中国技术 美卫星截不到