而在谷歌和IE上运行却是正常的。
JS代码:
<script>
window.onload = function(){
var txt = document.getElementById("txt");
txt.onfocus = function(){ //得到焦点
alert("得到了焦点"); //可以测试有没有得到焦点
}
txt.onblur = function(){
alert("失去了焦点"); //可以测试有没有失去焦点
}
}
</script>
</head>
<body>
<div>
<input type="text" id="txt" value="请输入..." ><button id="btn"></button>
</div>
</body>
在火狐上的效果是,当点击搜索框时,直接弹出“失去了焦点”;点击“确定”,会紧接着弹出“得到了焦点”。
不知道什么原因?