Status

being powerful doesn't mean being strong.

Well, someone at office asked me to disable normal/beginner users from copying our help website. So I search all over the Google and found some really nice tricks to do the task. Here how we can prevent users from copy/paste, right click, print screen and print command.

First we look at the JavaScript code for right click


var message="Function Disabled.";

function clickIE4(){
if (event.button==2){
alert(message);
return false;
}
}

function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
alert(message);
return false;
}
}
}

if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}

document.oncontextmenu=new Function("alert(message);return false")

Then disable the print command by using CSS for print.




Now we work on copy/paste and print screen. This method includes Adobe Flash to do the task. So on the first frame of flash frame copy and paste the ActionScript below and then include the flash file on any part of your page.

this.onEnterFrame = function(){
   System.setClipboard("As long as this page is open your copy/paste functionality has been disabled.");
}

Please note that Copy/Paste and Print Screen will remain disabled until you close the page.

Leave a Reply

Links: MiniBlog

  • BSOD Strikes During Beijing Olympic Games Opening Ceremony?
  • mysqlgame Are you tired of browser-based games that are thinly veiled interfaces for databases? Finally, there's a game that just is a database!
  • Moviemaker where the damn is it?
  • IT Guy Vs Dumb Employees some krazy guyz.
  • meow! i m just Chilling dude

Movies/TV shows I've watched recently:

Movie/TV shows ratings archive »