Solved

Disable Right Click + Paste in All Browsers

Posted on 2013-06-19
11
369 Views
Last Modified: 2013-08-05
I really need to disable paste (via the right click context menu) in all browsers.  I've tried a ton of scripts that are out there, but none have disabled ONLY the paste feature.  I'm trying to apply it with an inline script in the head tag of the iFrame created by jQuery's wysiwyg plugin.  So far, the only result I have achieved has been to disable right and left click.  Granted, I have only tested in FF.  I tend to save cross browser testing until after I can get it to work in FF, since FF tends to be the most lenient browser.  I would be fine with completly disabling right click if the paste function can't be singled out.  I am aware that the script could be circumvented simply by the user disabling JavaScript.  It's not on a 'website' per say, so the unwritten rules of the web don't apply here.  This is on a very user specific application, to which users are trained to use.  That being said, they don't listen to the part where we tell them not to paste from word....  Like most users, they are morons.  LOL

I really need to get this solved asap.  Any help you may offer would be greatly appreciated.  Thanks in advance!!!

~Brian
0
Comment
Question by:brianmfalls
  • 5
  • 3
  • 2
  • +1
11 Comments
 
LVL 2

Expert Comment

by:eli411
ID: 39260287
0
 
LVL 33

Expert Comment

by:Big Monty
ID: 39260426
wow...google results, very helpful, I'm sure the OP didn't think of that!

This code seems to work for me:
http://www.dynamicdrive.com/dynamicindex9/noright.htm
0
 
LVL 1

Author Comment

by:brianmfalls
ID: 39260474
eli411: Really???

The_Big_Daddy: I've tried that script, but it disables right and left click.  Keep in mind, it's being called from a dynamically created iFrame (via jquery.wysiwyg.js).  Further, the 'template' that calls jquery.wysiwyg.js is itself called via ajax.  It's a complicated piece to be sure...
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 2

Expert Comment

by:eli411
ID: 39260511
we love google!  ha ha!
0
 
LVL 33

Expert Comment

by:Big Monty
ID: 39260547
have you tried capturing the oncontextmenu event?

window.oncontextmenu = function () {
   return false;
}

https://developer.mozilla.org/en-US/docs/Web/API/window.oncontextmenu?redirectlocale=en-US&redirectslug=DOM%2Fwindow.oncontextmenu

without knowing what you tried, i'm just guessing here :)
0
 
LVL 1

Author Comment

by:brianmfalls
ID: 39260823
I believe so.  I won't be able to give that a shot until tomorrow.  My evening just exploded...  :)
0
 
LVL 43

Expert Comment

by:Chris Stanyon
ID: 39261935
Any user with a modicum of experience will use Ctrl+V instead of a right-click - if a simple user-interaction breaks your application, then I would seriously reconsider your design pattern.

If you're trying to prevent certain content being input into a field, then you might be better off allowing everything and stripping it server-side - that way, there's no fudging it.

Trying to force users into behaving in a specific manner is futile!
0
 
LVL 1

Author Comment

by:brianmfalls
ID: 39263988
Ctrl+V is disabled...  Honestly, you may all save both you and I time by skiping the lectures on why I shouldn't do this.  I know....  Really, I do.  More so, I agree.  However, it isn't my company, and therefore, it isn't 'my' application.  I can only advise on how things should be, then proceed as directed.  They want to disable right click, so I have to figure out how to disable right click within the application's user interface.  That's all there is too it.  So, while I sincerely agree with the advise and the futility of the exercise, it is not applicable to the situation.

I think the comment is warranted, and should stay in the post though, in case someone is just looking for a way to 'keep people from stealing their content'.  As if Alt+Print Screen didn't exist...  ;)
0
 
LVL 33

Accepted Solution

by:
Big Monty earned 500 total points
ID: 39265854
did capturing the oncontentextmenu event work?
0
 
LVL 1

Author Comment

by:brianmfalls
ID: 39265937
They told me to table this for the week.  I will try it as soon as I can.  It's their dime, so I need to respect that.  If I can try it sooner, I will!!!  :)
0
 
LVL 1

Author Closing Comment

by:brianmfalls
ID: 39383579
We weren't able to test this.  They decided to go with a different text editor, so we're doing just that...
0

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
In order to have all security and back ups taken care of, WordPress users can sign up for services with WP Engine.
The purpose of this video is to demonstrate how to exclude a particular blog category from the main blog page. This is can be used when a category already has its own tab, or you simply want certain types of posts not to show up on the main blog. …
The purpose of this video is to demonstrate how to add AdSense Ads to a WordPress Website, and how to set up WordPress to automatically place Ads in Sidebars. This will be demonstrated using a Windows 8 PC. Log into your AdSense account. : Cli…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question