Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Disable Right Click Javascript
01-09-2010, 02:47 AM (This post was last modified: 01-09-2010 02:47 AM by drdebcol.)
Post: #1
Disable Right Click Javascript
This is interesting JavaScript. It disables right click for visitors and they can't click to see source file. This can be helpful if you have some scripts that you want nobody to see. But there is one hack that you can do to see source. If site has ads (google ads, ad brite etc.) or some widget or addon, you can go right click on ads or widgets and view source.
So here is the source file :
Code:
<script language=JavaScript>
//This will disable the right click for guests at your site.
var message="Right click 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")
</script>

There's a fine line between genius and insanity. I have erased this line.
Oscar Levant
There's a fine line between an administrator and black hat hacker. I have erased this line.
Dr DEBCOL
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


 Quick Theme: