Are there any new solutions for copying multiple groups of text to the clipboard via JavaScript / Flash, since Flash 10?

Since Flash 10, many of the popular β€œcopy to clipboard” scripts have stopped working due to new security restrictions. There is only a Flash solution here:

http://cfruss.blogspot.com/2009/01/copy-to-clipboard-swf-button-cross.html

... although I'm looking for the ability to run the copy function through JS, instead of relying on the user to click the Flash object to run.

For an example of what we are currently using, see:

http://snipt.net/public

In any of the "copy" links, the jQuery copy plugin is used here:

http://plugins.jquery.com/project/copy

UPDATE: OK, so I tried ZeroClipboard. At first glance, it looked great. However, the amount of redundant code required to include multiple clipboard bindings is not valid. In some cases, there will be more than 40 copies of the text, each of which has its own copy link. Still looking for the best solution ...

+4
source share
2 answers

This terrible news, I did not even notice. I also use flash trick. As far as I know, this was the only way to get a copy to work without having to install any other plugin (other than the ubiquitous Flash) due to browser security issues.

Update. After a lot of panic and a few google searches, I came across a http://code.google.com/p/zeroclipboard/ which provides a flash 10 compatible trick to get a copy to work again. Now get around website updates ...

+4
source

This solution only works for keystrokes that will trigger the required operation. It works by moving the user cursor to the textarea element before the user completes the corresponding keystroke. It works only for text input. This works for me in firefox and chrome. IE can use the clipboardData object (which is preferable to this hack).

In html somewhere you should create a textarea element with arbitrarily large lines and cols attributes. The clipboard-textarea 'element will be the storage area for pasted and copied data. I hide the element using some style attributes.

script:

var desiredClipboardContents = 'It works'; function onCopyKeyPressed() { // The trick here is to populate the textarea with // the text you want copied before the user releases // the copy keystroke. var textarea = document.getElementById('clipboard-textarea'); textarea.value = desiredClipboardContents; textarea.focus(); textarea.select(); } function onPasteKeyPressed() { var textarea = document.getElementById('clipboard-textarea'); textarea.value = ''; textarea.focus(); // The trick here is to delay slurping the content // that arrives in the textarea element until after // the paste keystroke is completed. The 750 ms timeout // provides the necessary delay. setTimeout("finishedPasting", 750); } function finishedPasting() { var textarea = document.getElementById('clipboard-textarea'); alert("Received from clipboard-paste: " + textarea.value); } 
0
source

All Articles