function copyToClipboard(textToCopy) {
if (window.clipboardData) {
// IE
window.clipboardData.setData("Text", textToCopy);
} else if (window.netscape) {
// Firefox
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
if (!clip) return;
var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
if (!trans) return;
trans.addDataFlavor('text/unicode');
var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
var copytext = textToCopy;
str.data = copytext;
trans.setTransferData("text/unicode", str, copytext.length * 2);
var clipid = Components.interfaces.nsIClipboard;
clip.setData(trans, null, clipid.kGlobalClipboard);
}
alert("Following info was copied to your clipboard:\n\n" + textToCopy);
}
Firefox выдает предупреждение, чтобы не спрашивал надо прописать в конфиге: