鼠标单双击事件代码
2025年4月30日小于 1 分钟
示例代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>单双击事件</title>
</head>
<body>
<a href='http://www.sina.com' id='as'>请单击此处</a>
<!-- 阻止链接跳转 -->
<a href="javascript:void(0)" id='ae'>请双击此处</a>
</body>
<script type="text/javascript">
//获取对象
var as=document.getElementById('as');
//单击事件
as.onclick=function()
{
location.href='./1event_onbeforeunload01.html';
//阻止默认行为
return false;
}
//获取对象
var ae=document.getElementById('ae');
//双击事件
ae.ondblclick=function()
{
location.href='./1event_onbeforeunload01.html';
}
</script>
</html>