Don’t Modify the Clipboard with JavaScript

3429454121_9a93f53855_oRecently, I was reading an article about a newly published book that I’m interested in. However, the article didn’t include a link to the book, so I copied the title by highlighting it with the mouse and hitting ‘Ctrl-C’, and opened a new browser tab to do a search. However, upon pasting, I saw the book title along with an annoying addition: “To read more, visit our website at [redacted].”

This sort of website behavior is not okay.

I’ve seen the behavior on a number of websites, and it is among my least favorite trends in web development. The user is probably using his clipboard for one of two reasons. First, the website has a UX problem, and it has neglected to link to something important. Second, the user needs the text either for a quote, or to look up an unrelated term. For instance, this sentence has the word “bucolic” in it, and that’s an uncommon word that you might want to look up.

But you can’t easily, because I’ve included JavaScript on this page that modifies your copy buffer. Do you see how annoying that is? Please don’t go mucking about in your users’ copy buffers.

If you want to see what happens when you try to copy and paste on this page, highlight some text on the page and hit ‘Ctrl-C’ (or ‘Cmd-C’ for OS X users). Then go to the handy text area below and paste with ‘Ctrl-V’.

That’s really obnoxious, isn’t it?

The image for this post comes from Flickr user Shimelle Laine.

Leave a Comment