左键标示,IE里面是1,Google里面是0,右键都是2.
判断为左键,0或1都是
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<span id="t-p" οnmοusedοwn="whichButtonDown(event)" οnmοuseup="whichButtonUp(event)" οnmοusemοve="LeftButtonMove()">您好,欢迎登陆英才库招聘网</span>
<input id="OptType" name="OptType" type="text" value="-1">
<script language="javascript" type="text/javascript">
//鼠标左键按下 OptType=2
//鼠标左键抬起 OptType=3
function LeftButtonUp()
{
document.getElementById("OptType").value = "up";
//window.close();
}
function whichButtonDown(event)
{
var btnNum = event.button;
document.getElementById("OptType").value = "down" + btnNum;
}
function whichButtonUp(event)
{
var btnNum = event.button;
document.getElementById("OptType").value = "up" + btnNum;
}
//鼠标左键移动 OptType=4
function LeftButtonMove()
{
//document.getElementById("OptType").value = "4";
//window.close();
}
</script>
标签:function,Google,浏览器,OptType,btnNum,document,IE,event,左键
From: https://blog.51cto.com/u_16076050/6195823