Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Disable Right Click + Paste in All Browsers

Posted on 2013-06-19
11
Medium Priority
?
381 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 34

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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 2

Expert Comment

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

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 44

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 34

Accepted Solution

by:
Big Monty earned 2000 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The purpose of this video is to demonstrate how to integrate Mailchimp with WordPress, by placing a Mailchimp signup form on a WordPress Page or Post. This will be demonstrated using a Windows 8 PC. Mailchimp will be used. Log into your Mailchi…
The purpose of this video is to demonstrate how to set up the permalinks on a WordPress Website. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Go t…
Suggested Courses

824 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