Blocking Right-Click in Browser with JavaScript

This snippet code allows you to prevent the viewer from being able to right-click on your page. This can discourage the average user from borrow images or code from your site.

[View All Snippets]
Show Plain Text »
  1. <script type="text/javascript">
  2. function f1() {
  3.   if(document.all) { return false; }
  4. }
  5. function f2(e) {
  6.   if(document.layers || (document.getElementById && document.all)) {
  7.     if(e.which==2 || e.which==3) { return false; }
  8.   }
  9. }
  10. if(document.layers) {
  11.   document.captureEvents(Event.MOUSEDOWN);
  12.   document.onmousedown = f1;
  13. }
  14. else {
  15.   document.onmouseup = f2;
  16.   document.oncontextmenu = f1;
  17. }
  18. document.oncontextmenu = new function("return false");
  19. </script>
Create Your Free Account
Please remember that this information is essential to use our services correctly.
After creating the account you will be able to download all of our FREE products.
Fields marked with * are mandatory






Please send me information about updates, new products, specials and discounts from ApPHP!
We recommend that your password should be at least 6 characters long and should be different from your username/email. Please use only letters of the English alphabet to enter your name.

Your e-mail address must be valid. We use e-mail for communication purposes (order notifications, etc). Therefore, it is essential to provide a valid e-mail address to be able to use our services correctly.

All your private data is confidential. We will never sell, exchange or market it in any way. Please refer to Privacy Policy.

By clicking "Create Account", you are indicating that you have read and agree to the ApPHP Terms & Conditions.

Quick Registration with: Facebook / Google