We Recommend

Pro JavaScript Techniques Pro JavaScript Techniques
Pro JavaScript Techniques is the ultimate JavaScript book for the modern web developer. It provides everything you need to know about modern JavaScript, and shows what JavaScript can do for your web sites. This book doesn't waste any time looking at things you already know, like basic syntax and structures.


Posted By

localhorst on 03/18/08


Tagged

select copy protect mootools


Versions (?)


Who likes this?

2 people have marked this snippet as a favorite

SpinZ
blackabee


website copy protection


Published in: JavaScript 


I know what you think - no discussion about this needless piece of code to prevent copying texts/images from websites, but there are customers outside that are advising resistant and so I use this code to scare off their potential clienteles.

  1. // this needs mootools framework and disable rightclick or better the contextmenu
  2. document.addEvent('contextmenu',function(e){
  3. e=new Event(e);
  4. //alert('success');
  5. e.stop();
  6. });
  7.  
  8.  
  9. function selectnone() {
  10. document.body.ondrag = function () { return false; };
  11. document.body.onselectstart = function () { return false; };
  12. if(window.ie || window.opera){document.body.setProperty("unselectable","on");}
  13. if(window.gecko){document.body.setStyle("MozUserSelect","none");}
  14. if(window.webkit){document.body.setStyle("KhtmlUserSelect","none");}
  15.  
  16. }
  17.  
  18.  
  19. // call selectnone() onload/domready

Report this snippet 

You need to login to post a comment.