• Archives

  • AddThis Social Bookmark Button

    Add to Technorati Favorites

  • Upcoming Conferences

    • no upcoming events
  • Right mouse button was clicked or left ?

    By krates | June 1, 2008

    Sometimes you need to know which mouse button has been clicked you can use it block right click on page and many other things

    Syntax:

    <html>
    <head>
    <script type=”text/javascript”>
    function nb(event)
    {
    if (event.button==2)
    {
    alert(“You clicked the right mouse button!”);
    }
    else
    {
    alert(“You clicked the left mouse button!”);
    }
    }
    </script>
    </head>
    <body onmousedown=”nb(event)”>

    Click on the document to know which mouse button was clicked.

    </body>
    </html>

    Check this out by yourself by copying the above code in notepad and save it as .html page

    Thanks

    krates

    Share and Enjoy:
    • Digg
    • del.icio.us
    • Facebook
    • NewsVine
    • Reddit
    • StumbleUpon
    • YahooMyWeb
    • Google Bookmarks
    • Yahoo! Buzz
    • TwitThis
    • Live
    • LinkedIn
    • Pownce
    • MySpace

    Topics: Javascript | Comments Off

    Related Links:

    Comments are closed.