12

Here is an example of what happens when pasting text from Financial Times, the top paragraph is added.

Thanks in advance!

Example:

Please respect FT.com's ts&cs and copyright policy which allow you to: share links; copy content for >personal use; & redistribute limited extracts. Email ftsales.support@ft.com to buy additional rights >or use this link to reference the article - http://www.ft.com/cms/s/0/792f1aec->9600-11e0-8256-00144feab49a.html#ixzz1PFrYZiD0

Goldman Sachs gave a paid internship to a top Libyan official’s relative while the bank was carrying >out lossmaking trades on behalf of the country’s sovereign wealth fund, the Financial Times has learnt.

John Cartwright
  • 5,109
  • 22
  • 25
ok1ha
  • 637
  • 1
  • 11
  • 30
  • Do you mean, "pasting text **onto** the Financial Times", or "pasting text that was copied **from** the Financial Times"? – Pointy Jun 14 '11 at 13:56
  • try, it's from the FT :) – red eyes dev Jun 14 '11 at 13:56
  • That's very interesting indeed. I don't have an answer, but intend to find one. – Niklas Jun 14 '11 at 13:58
  • 2
    http://stackoverflow.com/questions/2026335/how-to-add-extra-info-to-copied-web-text – James Montagne Jun 14 '11 at 13:58
  • See http://stackoverflow.com/questions/6098068/what-text-can-be-copied-but-not-searched-for/6098284#6098284 for an answer I posted recently which shows one way of achieving this sort of thing using pure CSS. – Spudley Jun 14 '11 at 13:59
  • To answer your specific question: FT use a service called Tynt that both adds and tracks the copy action by using JS to add hidden content to the user's selection. That leads to a more general question: how would I do that? That's one I've already asked: http://stackoverflow.com/questions/2026335 – Keith Sep 19 '11 at 09:22
  • You can try the solution of this post, it worked for me like a breeze : http://stackoverflow.com/questions/16238142/get-the-users-copied-text-in-jquery-and-rewrite-the-paste – Cedric Jun 06 '13 at 08:49

5 Answers5

10

As already previously mentioned, modifying the clipboard data is either restricted to specific browsers or requires the user to grant access to modifying the clipboard. A work around to this you could

  1. Add an event handler to the oncopy event
  2. Find the selection
  3. Prepend/append content to the content
  4. Modify the selection range to include the appended/prepended content
  5. Wait for the copy action to push through
  6. Remove the appended/prepended content

I fiddled about with this method and created a plugin which does just that. Still a preliminary version and only tested on FF4/Chrome 11/IE8 so far (and IE definetly needs to have some more work done). Some of the nice things you can do with this method is that you could easily for example wrap forum post quotes in [quote=USER]content[/quote] and assign the user based on which post is copied. By default, the script always selects the DOM styling, but not the actual HTML, so if you for example copy bold content, it would be bold if pasted into a rich text editor, but just text if used in text only editors (removing the html tags).

Prepending content is significantly easier with this method, compared to appending, in which case I still am not sure whether it is fully functional. For IE, you could directly modify the clipboard, but there are some issues for example when selecting the whole page, or if you want to toggle the rich copy content. Haven't had the chance to do any further browser testing, but this appears to be at least a working solution for newer browsers.

Example: http://hertzen.com/experiments/jquery.plugin.clipboard/

Another example: http://hertzen.com/experiments/jquery.plugin.clipboard/thread.html

Source code: https://github.com/niklasvh/jquery.plugin.clipboard

Niklas
  • 29,752
  • 5
  • 50
  • 71
6

You implement a handler for the oncopy event. By manipulating the clipboardData object, you can change the copied text.

Ernest Friedman-Hill
  • 80,601
  • 10
  • 150
  • 186
  • 1
    Modifying the clipboardData only works with IE, and the workaround shown there for FF throws a security exception on later versions of FF at least. – Niklas Jun 14 '11 at 15:08
  • 1
    That only works in older IEs (it doesn't in 8 or 9) and is a security bug - javascript shouldn't have the ability to manipulate clipboard data. – Keith Sep 19 '11 at 09:16
5

Webmaster use Javascript for that.

Check file http://media.ft.com/j/FTTrack2.js

FT.Tynt={
    initTynt:function(){
        var Tynt=Tynt||[];
        Tynt.push('cqolxGrS4r34rIadbiUt4I');
        Tynt.i={
            "cc":"0",
            "b":true,
            "ap":"Please respect FT.com's <a href='http://www.ft.com/servicestools/help/terms'>ts&amp;cs</a> and <a href='http://www.ft.com/servicestools/help/copyright'>copyright policy</a> which allow you to: share links; copy content for personal use; &amp; redistribute limited extracts. Email ftsales.support@ft.com to buy additional rights or use this link to reference the article -",
            "t":true
        }
Rup
  • 33,765
  • 9
  • 83
  • 112
red eyes dev
  • 398
  • 3
  • 11
4

This is something you can achieve via a jQuery plugin named jquery copy. Here's an example using the p selector.

$("p").click(function() {
    $.copy($(this).text() + " Disclaimer goes here!");
});
KyleMit
  • 30,350
  • 66
  • 462
  • 664
User1578
  • 628
  • 1
  • 5
  • 9
  • 3
    That's predefined selection that's copied. With FS you can perform your own selection and it prepends the disclaimer on it. (+.$copy is a plugin, and not part of jquery) – Niklas Jun 14 '11 at 14:02
4

They use JavaScript which can be found in the following file:

http://media.ft.com/j/FTTrack2.js

Kara
  • 6,115
  • 16
  • 50
  • 57
Will
  • 137
  • 1
  • 1