I need a way to copy dynamically (Ajax) uploaded content to the clipboard in a web browser. There are many libraries that will simulate the function of copying to the clipboard using Flash. However, with the new default security settings for Flash 10 , setting the copy to clipboard now requires explicit user confirmation. ZeroClipboard is a Javascript / Flash library that bypasses this "limitation" (using flash clicks).
This is a simple jQuery plugin that I wrote to integrate ZeroClipboard into my application:
(function($) {
$.fn.clickToClipboard = function() {
$(this).each( function() {
var link = $(this);
if ( link.is('a') ) {
var clip = new ZeroClipboard.Client();
clip.glue(this);
clip.addEventListener('onMouseDown', function(){
link.html('copying...');
clip.reposition();
$.ajax({
url: link.attr('href'),
success: function(content) {
clip.setText(content);
},
async: false
});
});
clip.addEventListener('onComplete', function(){
link.html('copied!');
clip.reposition();
});
}
});
}
})(jQuery);
URL . - ( ), Ajax ZeroClipboard.
Safari ( prototype.js 4000+). FF3.0 : "". Ajax . , , . , ( Ajax).
, Ajax , . - , , ? ( , , Rails).