我正在尝试构建一个图像,如果我可以按任何按钮并获取是否有右,左,或者双击。
像这些:
<img id="myImgId" alt="" src="image.jpeg" onmousedown="click(event)"/>
<p><span id="click"></span></p>
<script type="text/javascript">
function click(event)
{
if(event.button==2)
{
document.getElementById("click").innerHTML="Last Action: Right Click";
document.getElementById("click").value="Last Action: Right Click";
}
else if(event.button=0)
{
if(event.getclickcount() = 1)
{
document.getElementById("click").innerHTML="Last Action: Left Click";
document.getElementById("click").value="Last Action: Left Click";
}
else if(event.getclickcount() = 2)
{
document.getElementById("click").innerHTML="Last Action: Double Click";
document.getElementById("click").value="Last Action: Double Click";
}
}
}
</script>
我期待当我点击图片时,这会做一些事情......