firefox中onmousedown与onkeydown互相干扰的问题,各位大侠看下
当我在一个层中同时设置了onmousedown onkeydown事件时,只有onmousedown的事件有用,而onkeydown事件没有用,如果把onmousedown去掉的话,而onkeydown可以正常使用.例子代码:<html>
<head>
<title> 键盘代码 </title>
</style>
</head>
<body >
<div id="div1" style="width:300px;height:400px;border:1px solid black;" >
hahaha
</div>
<div tabindex=0 id="ff" style="border:1px solid red;width:500px;height:50px" onmousedown="shows(event)" onkeydown="showKeydown(this.id,event)">
kfjlsdkjfklsjdkl
<div>
<br/><br/>
<input id="b1" type="button" value="create div" onclick="getdd()"/>
<p align= "center "> 请点下鼠标再按键盘 </p>
<script>
function showKeydown(r,e){
alert("keydown");
if(!e)e=window.event;
alert( "ASCII代码是: "+e.keyCode);
alert("r"+r);
return false;
}
function shows(e)
{
alert("ff");
return false;
}
function getdd()
{
var pd=document.getElementById("div1");
var newDiv="";
newDiv += "<div tabindex=0 id='tt' title='kk' name='fs'" ;
newDiv += "style='border:1px solid red;position:absolute;left:33px;top:43px;cursor:hand;' onkeydown='showKeydown(this.id,event)' onmousedown='shows(event)' >";
newDiv +="kkkkkkkkk";
newDiv+= "</div>";
newDiv += "<div tabindex=0 id='df" ;
newDiv += "' style='border:1px solid blue;' onkeydown='showKeydown(this.id,event)' onmousedown='shows(event)' >";
newDiv +="ffffffffffffffff";
newDiv+= "</div>";
pd.innerHTML += newDiv;
}
</script>
</body>
</html>