1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
<script type="text/javascript">
function detectRightClick(evt)
{
var e=evt?evt:window.event?window.event:null;
if (e.which == null){//* IE
button= (e.button < 2) ? "Gauche" : ((e.button == 4) ? "Milieu" : "Droite");
}
else{// Autres
button= (e.which < 2) ? "Gauche" : ((e.which == 2) ? "Milieu" : "Droite");
}
alert(button)
}
</script>
</head>
<body onload=" document.getElementById('mydiv').onmousedown = detectRightClick">
<div id="mydiv"> text</div>
</body>
</html> |