Для chrome, ie и ff41+
(function() {
'use strict';
var nfclip = null;
if (window.clipboardData && window.clipboardData.setData) {
nfclip = function(text) {
return window.clipboardData.setData('Text', text);
};
} else if (document.queryCommandSupported) {
var area = document.createElement('textarea');
area.style.opacity = '0';
area.style.position = 'fixed';
area.style.top = '-999999px';
area.style.left = '-999999px';
document.body.appendChild(area);
nfclip = function(text) {
area.value = text;
area.focus();
area.select();
return document.execCommand('copy', false);
};
}
if (!nfclip) {
nfclip = function() {
return false;
}
nfclip.supported = false;
} else {
nfclip.supported = true;
}
window.nfclip = nfclip;
if (window.$) {
window.$.nfclip = nfclip;
};
})()
Для остальных
zeroclipboard.org