The Internet Connection
(May 2000 Action for Libraries newsletter)

By Michael Sauers

JavaScript Can Disable Right Button on Mouse
Do you have a graphic on your library Web site that you don't want stolen? When the script below is added to the coding of a Web page, it disables the right mouse button while the user is on that page. The user browsing your Web page will no longer be able to right-click on the image and "Save Image As." Instead of the normal menu appearing when the user clicks on the right button, an alert window appears that displays a message of your choice. This makes it difficult, although not impossible, for a user to steal your graphics.

<script language="JavaScript">

  <!--
  function click()
      {
     if (event.button==2)
           {
           alert('The right mouse button has been disabled.');
                  }
       }
  document.onmousedown=click
  //  -->
  </script>

(NOTE: When writing the script, lines seven and eight must appear as a single line. Indent as indicated.)


BCR Home Page Table of Contents