如对象在一人页面上有两上对象A和B,右键点A时触发事件A1,右键点B时触发事件B1,点页面其它地方不触发事件,不知这个如何写,
注,不是页面的右键。
---------------------------------------------------------------
1<span onmousedown="a1()">a</span>
1<script>
2function a1()
3{if(event.button!=2)
4return false;
5//your code here
6}
7</script>
---------------------------------------------------------------
function displaymenu(){
s=event.srcElement.id;
if(s.indexOf("a")){//判断点击的位置
//你的操作
}
if(s.indexOf("b")){//判断点击的位置
//你的操作
}
return false;
}
document.oncontextmenu=displaymenu;