Click here to Skip to main content
Click here to Skip to main content
Alternative Tip/Trick

Tagged as

Disable right click context menu cut, copy, paste

, 25 Nov 2011 CPOL
Rate this:
Please Sign up or sign in to vote.
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...
<script type="text/javascript">
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")
</script>
This Will Work.I have tested In: Internet Explorer, Mozilla Firefox, Google Chrome.

No matter what you do, you can't prevent users from having full access to every bit of data on your website. Any Javascript you code can be rendered moot by simply turning off Javascript on the browser (or using a plugin like NoScript).

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

No Biography provided

Comments and Discussions

 
Questionnot working in google chrome Pinmemberndsolanki.it20-Nov-12 0:06 
GeneralReason for my vote of 1 See my comments for the original ver... PinmemberLFD-Mike25-Nov-11 9:15 
GeneralThis Code also Work...But When Disable Javascript it wont wo... PinmemberPrince Antony G24-Nov-11 19:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web02 | 2.8.141029.1 | Last Updated 25 Nov 2011
Article Copyright 2011 by Prince Antony G
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid