You probably don't have the budget to make sure this works properly as you intend it everywhere it's accessible, and by introducing it you're actively making your site, and by extension my experience, less reliable and less predictable.
Excel ends up populating the plaintext as well as the HTML paste buffers. The plaintext buffer holds TSV output and the HTML buffer holds the full HTML. The HTML is the only way to distinguish between the two cells
|"foo|bar"|
and the single cell |"foo\tbar"| (using some CHAR magic in excel to generate the tab character)
my short spiel: http://blog.sheetjs.com/post/66908170192/the-magic-behind-ex...If you use keyboard short-cuts in your UI to copy into your app's memory but not the system clipboard then you have no way to know whether the data the user wants to paste was copied from your app or somewhere else. If you only use the system clipboard and inform the user that copy/pasting is done with right-click or key-combos and not the browser's "Edit" menu, you can handle copy-pasting predictably.
This was the most reliable method I could think of. Yes the browser's "Edit" menu is a problem and there's no way to get around that.
1. Disable Javascript. I browse with NoScript / Scriptsafe plugs installed, and disable JS by default. This defeats the demo in the article (I actually had to enable JS to break my copy/paste).
2. Use a console-mode browser and/or curl the source and grab what you want from it (though I've found sites which break console tools).
Better: enter domains which employ such tactics in your /etc/hosts file as 0.0.0.0.
As far as I can tell, blocking *.tynt.com cuts down on 99% of such gimmmicky tactics.
(I wonder why they're such a major provider; the paranoid in me wants to believe that they're using patents aggressively; the lazy person in me doesn't care.)
I wrote that post with the intention of using the solution in apps to copy/paste app data in plain text - eg. selecting multiple objects in a drawing app and copying them as a JSON string.
I guess NoScript/Ghostery/AdBlock Plus could be considered solutions to your problem.
Not necessarily a solution, as you can do it with css only. For example, people can put a 0-sized snippet at the end of the text, and then pad with some non-copyable text, so you select ABC, end up copying AB<something else>.
IIRC twitter does this for urls (think "http://oo.com…").
taye, I apologize if this isn't a constructive comment but this feature has annoyed me from time to time. Forbes.com just implemented it.
As I mentioned in another comment, I use NoScript to disable javascript so I wouldn't even notice that kind of thing. I agree that that is unnecessary and sort of abusive to users. I only intended on using this within web apps like a document editor etc.
As for trying it on the linked site, I have NoScript installed. Good luck trying to prevent me from copy-and-pasting now.
I right clicked on your "intercepting element," inspected with firebug, and deleted the input node. Then I could copy and paste as I desired. Firefox. 10 seconds?
My point is, we have many better things to spend our time on as developers than trying to control our user's access to the same information we're providing them. This not a reproach to taye, but to the bosses that ask us to build these worthless systems.
Bonus: you can get (on paste) and set (on cut and copy) data in multiple file formats. And obviously you can pre-process pasted data before injecting it in the system.
Try right-clicking here to see this workingDetecting a long hold and then selecting the text before the usual mobile context menu pops up could be good enough. I only devised this solution for a desktop app.