在onfocusout事件中能区分是用鼠标还是用键盘触发的吗? 页面上的文本输入框,在焦点离开后,检查用户输入的数据。因为使用鼠标和使用键盘我的程序处理不一样,所以请问:在onfocusout事件中,有没有参数指明,是按键盘TAB,还是鼠标点在别的输入框中触发的? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 做了个例子,lz参考下吧,希望对lz有用^_^<html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>新建网页 5</title><script>function aaa(obj){if(typeof(obj.hasblur)=='undefined'){alert("鼠标操作");}else{alert("键盘操作");}}function bbb(obj){if(event.keyCode==9){obj.hasblur = true;}}function ccc(obj){obj.removeAttribute("hasblur");}</script></head><body><input id=t type=text value="" onblur="aaa(this)" onkeydown="bbb(this)" onfocus="ccc(this)"></body></html> FF好像本身不支持onblur,onfocus事件的...看看有没有其他什么办法解决 FF 支持onblur,onfocus事件. 想不到这也行。原来我是希望,使用事件的参数,例如event.keyCode之类,不过我没试出来。 稍微改了下,支持IE和FF<html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>新建网页 5</title><script>window.onload = function (){ var obj = document.getElementById("t"); obj.onblur=function (){ if(obj.hasblur){ alert("键盘操作"); }else{ alert("鼠标操作"); } }; obj.onkeydown=function (e){ if(!e) e=event; if(e.keyCode==9){ obj.hasblur = true; } }; obj.onfocus=function (){ obj.hasblur=false; };}</script></head><body><input id=t type=text value=""></body></html> 多个JS可以调统一的变量的吗? 什么是正弦?什么是余弦?什么是反余弦? 怎么让第2个form有效.... IE缓存影响登陆问题 初学javascrip 求下面程序的意思,回答者都有分 关于像素的显示问题 <求助>关于无组件上传问题 请问怎样刷新页面??? 请问我的这个连接数据库的代码,为什么浏览器认为网页有错误? 如何使得checkPic()检测有效,阻止提交?马上给分。 怎么在JS中和<object>控件对象交互 为什么处理语句写在子函数中就不行了?
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>新建网页 5</title>
<script>
function aaa(obj){
if(typeof(obj.hasblur)=='undefined'){
alert("鼠标操作");
}else{
alert("键盘操作");
}
}function bbb(obj){
if(event.keyCode==9){
obj.hasblur = true;
}
}
function ccc(obj){
obj.removeAttribute("hasblur");
}
</script></head><body>
<input id=t type=text value="" onblur="aaa(this)" onkeydown="bbb(this)" onfocus="ccc(this)">
</body></html>
原来我是希望,使用事件的参数,例如event.keyCode之类,不过我没试出来。
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>新建网页 5</title>
<script>
window.onload = function (){
var obj = document.getElementById("t");
obj.onblur=function (){
if(obj.hasblur){
alert("键盘操作");
}else{
alert("鼠标操作");
}
};
obj.onkeydown=function (e){
if(!e) e=event;
if(e.keyCode==9){
obj.hasblur = true;
}
};
obj.onfocus=function (){
obj.hasblur=false;
};
}</script></head><body>
<input id=t type=text value="">
</body></html>