Search code examples
javascripteventsmouseclick-event

How to detect side mouse clicks in Javascript?


Is it possible to detect using JavaScript when the user clicks the back/forward buttons that are the side of your mouse ? These are known as XButtons as far as I know, in .net at least. This is for a locally installed app so I don't need cross browser support, just something that works in IE.


Solution

  • This cannot be done. The most sophisticated mouse click events you will get is left and right.

    <script type="text/javascript" language="javascript">
        function testMouseClick()
        {
            if(event.button == 1)
            {
            alert("Left Mouse Click is Pressed..");
            }
            if(event.button == 2)
            {
            alert("Right Mouse Click is Pressed..");
            }               
        }
    </script><