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?
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?
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 Control-A and Control-C, but I hate that so much that I'm not going to tell you how to do it. You can downvote me all you like!
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 ->"
That's the third question in a row which is about to "prevent" or "disable" some basic functionalitys.
You might think about User experience
and usability
.
update
You mentioned in your comment that you're dealing with sensitive data. I agree with the other comments that you should not send such sensitive
data to the client. There is just no way to protect it.
Pen and paper are still not deprecated.
Then there are screen capture tools, cameras, etc.
And there is always the human memory.
Finally, a browser is just a convenience which is not even needed. Someone can just curl in a http(s) request with whatever headers and/or data your server is expecting. No browser, no DOM, no events, just plain text on the command line. How do you control that?