Solved

Disable Right Click + Paste in All Browsers

Posted on 2013-06-19
11
373 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
  • +1
11 Comments
 
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

WordPress is constantly evolving, and with each evolution appears to get better and better.  One of the big drawbacks prior to version 3 was that there was no way to be able to set up a custom menu from the backend. The Old Way Adding menus is…
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…
This video teaches viewers how to create their own website using cPanel and Wordpress. Tutorial walks users through how to set up their own domain name from tools like Domain Registrar, Hosting Account, and Wordpress. More specifically, the order in…
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.
Suggested Courses

635 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