jqueryhtml

How to disable copying text on certain pages in the user interface


Env: jQuery, richfaces

We would like to disable copying (using CTRL+A) sensitive information on certain pages and pasting via the clipboard. We would rather expect the user to use few buttons to export the data. How do we achieve this?


Solution

  • You cannot. It is the user's computer and they can copy any data that they can see.

    Now you can annoy the hell out of them by having some JavaScript that intercepts keys like Ctrl+A and Ctrl+C*.

    I suppose a nice middle ground would be to detect when the user tries to copy and not disallow it, but display some kind of a message along the lines of "Hey, are you trying to export the data? Try the Export button over there ->"