free hosting   image hosting   hosting reseller   online album   e-shop   famous people 
Free Website Templates
Free Installer

Disabling The Right Mouse Button


Want to stop people from viewing your Source code?

Want to disable saving graphics from your page?

Then this script will do the job:
Paste the above code into the head section of your page.

It will disable the right (or 3rd) mouse button, as well as prevent the context menu from being displayed.

But there is one drawback.

If this is inserted in a stand-alone page, people will still be able to view your Source code from the main menu bar.

But if your page is inside frames, all they'll see is the framset information.


How It Works

The script first looks to see if an event such as a mouse click is taking place.

Two functions are now called:
  • nocontextmenu disables the context menu from being displayed
  • norightclick disables the right or 3rd mouse button
  • Since the button event handlers are different for IE and Netscape, 2 variations are included:
  • e.which for IE
  • event.button for Netscape

  • Try It Out

    Right click anywhere on this page and see what happens.




    © 2001 CyberSchool
    Last Update: