<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns= "http://www.w3.org/1999/xhtml" >
<head>
<title> compatible with IE and Firefox copy to clipboard effect </title>
<meta http-equiv= "Content-type" content= "text/html;charset=gb2312" >
</head>
<body>
<!--Add the following code to <body> and </body>-->
<input type= "text" id= "Copyvalue" name= "Copyvalue" value= "www.zzsky.cn" >
<input type= "Submit" value= "Copy to Clipboard" onclick= "CopyToClipboard (document.getElementById (' Copyvalue '). Value);" >
<script type= "Text/javascript" >
function CopyToClipboard (TXT) {
//ie
if (window.clipboarddata) {
Window.clipboardData.clearData ();
Window.clipboardData.setData ("Text", txt);
alert (IE replication success!) ");
}
//firefox
else if (window.netscape) {
try{
Netscape.security.PrivilegeManager.enablePrivilege ("Universalxpconnect");
}catch (e) {
alert ("Rejected by browser!") n Please enter ' About:config ' in the browser address bar and return to N and set ' Signed.applets.codebase_principal_support ' to ' true '.
}
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 = new Object ();
var len = new Object ();
var str = components.classes["@mozilla. Org/supports-string;1"].createinstance ( Components.interfaces.nsISupportsString);
var copytext = txt;
str.data = CopyText;
trans.settransferdata ("Text/unicode", str,copytext.length*2);
var clipid = Components.interfaces.nsIClipboard;
if (!clip) {
return false;
}
Clip.setdata (Trans,null,clipid.kglobalclipboard);
alert ("Firefox replication success!") ");
}
}
</script>
</body>
</html>