Mouse Buttons

For a quick and simple method to block access to the context menu from the mouse button and the keyboard options
see oncontextmenu

The following gives you the necessary information to identify which mouse button is pressed. Press a button to see which number goes bold

BrowserSyntaxLeftRightWheel
IEevent.button124
Moz & NS7e.which132

<script type="text/javascript">
<!--

if(document.layers){
document.captureEvents(Event.MOUSEDOWN);
}

function which_browser(e){

if(document.all){ // IE
alert(event.button)
}

if(document.getElementById&&!document.all){ // Moz NS7
alert(e.which)
}

if(document.layers){ // NS4
alert(e.which)
}

}
document.onmousedown=which_browser

// -->
</script>






if (event.button==2){
alert('You cannot Right-Click here.')
}

if (event.button==1){
alert('You cannot Left-Click here.')
}

if ((event.button==1)||(event.button==2)){
alert('You cannot Click here.')
}

Note:

Detect which button is clicked in firefox with the button property of the event passed to the handler
0 - left
1 - middle
2 - right
If the event's button value is not 0 (left button) you can use preventDefault() and stopPropagation() to halt the event processing.
It is best to use this on individual elements, and not the window object itself.