Click here to Skip to main content
15,668,777 members
Articles / Web Development / ASP.NET
Posted 4 Aug 2011

Tagged as


9 bookmarked

Disable right click context menu cut, copy, paste

Rate me:
Please Sign up or sign in to vote.
3.82/5 (7 votes)
5 Aug 2011CPOL
<script type="text/javascript">
document.oncontextmenu=new Function("return false");


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

Written By
Software Developer Vbsoft India Ltd
India India
Working as Software Developer with 2 year exp.

Comments and Discussions

GeneralWhat if i want to restrict user to copy content/ text from p... Pin
Jαved13-Jan-12 3:39
professionalJαved13-Jan-12 3:39 
GeneralReason for my vote of 1 Easily defeated by disabling js. Ver... Pin
MadMyche25-Nov-11 9:13
professionalMadMyche25-Nov-11 9:13 
GeneralWould like to comment that any method of prevention is entir... Pin
Ed Nutting24-Nov-11 20:18
Ed Nutting24-Nov-11 20:18 
Would like to comment that any method of prevention is entirely pointless - large numbers of users do not right click and instead go through the edit menu. Furthermore, unless you can disable Developer Tools - which you can't - I do not see why you are trying to block the default context menu. The only time I have found it helpful to block the default context menu was when I wanted my own one for an online editor I was producing. In which case, a jQuery plugin did the job nicely - jQuery is far better for stuff like this.

Generallots of thanks to you for the article as it solved my great ... Pin
Denno.Secqtinstien18-Nov-11 0:02
Denno.Secqtinstien18-Nov-11 0:02 
GeneralReason for my vote of 5 nice very nice super duper hit code ... Pin
Denno.Secqtinstien17-Nov-11 23:52
Denno.Secqtinstien17-Nov-11 23:52 
GeneralReason for my vote of 5 This is very useful code. Now i am e... Pin
ganpati19-Aug-11 2:48
ganpati19-Aug-11 2:48 
GeneralReason for my vote of 3 nowdays nobody uses new Function yo... Pin
GottZ8-Aug-11 21:04
GottZ8-Aug-11 21:04 

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

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