The code is as follows, so I won’t talk nonsense. It is compatible with basically all mainstream browsers (IE, FF), and can be used in many places:
copyToClipboard = function(txt) {
if() {
();
(”Text”, txt);
} else if((”Opera”) != -1) {
= txt;
} else if () {
try {
(”UniversalXPConnect”);
} catch (e) {
alert("Your firefox security restrictions restrict you from performing clipboard operations, please open 'about:config' and set .codebase_principal_support' to true' and try again");
return false;
}
var clip = ['@/widget/clipboard;1′].createInstance();
if (!clip)
return;
var trans = ['@/widget/transferable;1′].createInstance();
if (!trans)
return;
('text/unicode');
var str = new Object();
var len = new Object();
var str = [”@/supports-string;1″].createInstance();
var copytext = txt;
= copytext;
(”text/unicode”,str,*2);
var clipid = ;
if (!clip)
return false;
(trans,null,);
}
}
copyToClipboard = function(txt) {
if() {
();
(”Text”, txt);
} else if((”Opera”) != -1) {
= txt;
} else if () {
try {
(”UniversalXPConnect”);
} catch (e) {
alert("Your firefox security restrictions restrict you from performing clipboard operations, please open 'about:config' and set .codebase_principal_support' to true' and try again");
return false;
}
var clip = ['@/widget/clipboard;1′].createInstance();
if (!clip)
return;
var trans = ['@/widget/transferable;1′].createInstance();
if (!trans)
return;
('text/unicode');
var str = new Object();
var len = new Object();
var str = [”@/supports-string;1″].createInstance();
var copytext = txt;
= copytext;
(”text/unicode”,str,*2);
var clipid = ;
if (!clip)
return false;
(trans,null,);
}
}