to home page

BWRS
SEARCH

HOMETUTORIALSLINKSFORUMGLOSSARYNEWS
 
COOL TIPS >
No Right Click   
Save 50-70% on INK cartridges.
advertisement

How To Stop Right Clicks

One of the problems with any good site is people are going to pinch your images etc.Given the fact you just need to right click over any image this is very easy. There is no easy way to stop this but with a little bit of JavaScript you can make things a little harder for internetexplorer users by locking out right clicking (Although users of v4.x or earlier Netscape will be unaffectred and there are still tons of ways to get round this for IE users)

Try this example


Here's the code

Pop it in between your <meta> tags go between <head> and </head> tags on an HTML document (composer and frontpage express users should use add HTML functions for this)

<script language="javascript">
<!--//
function press()
{if (event.button==2) {
alert('sorry, you cannot do that')}}
document.onmousedown=press
//-->
</script>

The code works by defining the function press to trigger an alert box if the right mouse button (button==2) is pressed. It needs the document statement to trigger it when the mouse buttons are pressed (onmousedown)

You can change the alert box message (just avoid using' or "). You can also (if you're truely insane) disable the left button instead by changing button==2 to to button==1)

Remember this is only a minor measure that only works on some browsers and, even with them, it can be easily overcome


back to How to
BACK TO INDEX
Back to top