How can I check whether left or right mouse button has been clicked?

To determine whether the user clicked the left or right button, you can use the following properties. # Event.which in Netscape Navigator # event.button in Internet Explorer

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

  
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
    <script type="text/javascript">
          <!--
          function mouseDown(e)
          {
                if (parseInt(navigator.appVersion)>3)
                {
                    var clickType=1;
                     if (navigator.appName=="Netscape") clickType=e.which;
                    else clickType=event.button;
                    if (clickType==1)
                    {
                         self.status='Left button!';
                         alert("Left Button");
                     }
                if (clickType!=1)
                     {
                          self.status='Right button!';
                         alert("Right Button");
                    }    
               }
           return true;
          }
          if (parseInt(navigator.appVersion)>3)
          {
                document.onmousedown = mouseDown;
                if (navigator.appName=="Netscape")
                document.captureEvents(Event.MOUSEDOWN);
          }
          //-->
          </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:Panel ID="Panel1" runat="Server" GroupingText="Test">
    <asp:TextBox ID="txtBox" runat="Server"></asp:TextBox><br />
    <asp:Button ID="btnTest" runat="Server" Text="Submit" />
    </asp:Panel>
    </div>
    </form>
</body>
</html>

Please do not post any spam link in the comment box😊

Post a Comment (0)
Previous Post Next Post