Solved

Disable Right Click + Paste in All Browsers

Posted on 2013-06-19
11
370 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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
WordPress can be pretty daunting, especially for a beginner, so I thought it might be a good idea to write an article to show how easy it is to get started in WordPress and to design a custom theme.  The first step is to check with your hosting comp…
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 prevent comment spam on a WordPress Website. This will be demonstrated using a Windows 8 PC. Plugin Akismet will be used. Go to your WordPress login page. This will look like the following: myw…

808 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