场景:作为javascript字段验证的一部分显示警告消息onblur(或onchange).
使用onblur的用户操作:
1)单击内部输入
2)在输入外单击
3)关闭警报消息
4)移动鼠标左右
结果: mousedown似乎是在警报出现之前单击的位置执行的 - 当您移动鼠标时,页面上的元素会被选中.
注意:在输入选项卡时不会发生这种情况.
演示: http ://jsfiddle.net/s9sc4/
<body>
Click inside the input and then outside of it.
<input type="text" onblur="alert('Close this alert message and move the mouse around.');" />
TEST TEST TEST
</body>
Run Code Online (Sandbox Code Playgroud)
转载于:
Firefox 28和29平台:Windows 7和8以及OSX Mavericks(4种不同的机器).
使用干净的Firefox配置文件没有任何区别.
问题:
这是一个错误,还是默认行为?Chrome,Safari和IE不会像这样.
如果它是设计的,我是否需要使用preventDefault执行某些操作或在警报后取消冒泡/停止传播以停止此行为?