解决鼠标单双击事件冲突

2015-09-18 15:33:31

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>测试页</title>
<script type="text/javascript">
//万恶的ie不支持
var d=0;
function c(){
_interval =new Date().getTime() - d;
d = new Date().getTime();
function c1(){
if(_interval<500)return;
alert("单击");
}
function c2(){
alert("双击");
}
if(_interval<500){
c1 = c2;
}
setTimeout(c1,500);
}
</script>
</head>
<body>
<input name="test" id="test" type="button" onmouseup="c()" value="单双击测试"/>
</body>
</html>

点赞

发表回复

电子邮件地址不会被公开。必填项已用 * 标注