Solved

Disable Right Click + Paste in All Browsers

Posted on 2013-06-19
11
367 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 32

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
 
LVL 2

Expert Comment

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

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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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 42

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 32

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Do you think that WordPress is just for blogs?  Think again!  WordPress is really a fantastic all around platform that you can use to develop websites on.  Integrated into its basic functionality is the ability to create pages using your choice of a…
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 users how to migrate an existing Wordpress website to a new domain.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

708 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now