//经测试,该方法只适用于IE function copyToClipBoard(url,title){ var clipBoardContent=""; clipBoardContent+=title; clipBoardContent+=""; clipBoardContent+=url; window.clipboardData.setData("Text",clipBoardContent); alert("复制成功,请粘贴到你的QQ/MSN上推荐给你的好友"); } //经测试,该方法兼用IE FireFox function copy_url(url,title){ var clipBoardContent=""; clipBoardContent+=title; //获取标题 clipBoardContent+="/n"; clipBoardContent+=url; //获取地址 if (window.clipboardData){ window.clipboardData.setData("Text", clipBoardContent);] }else if (window.netscape){ 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 = new Object(); var len = new Object(); var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString); var copytext=clipBoardContent; 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("复制成功,您可以发送给你的好友啦!"); } </script>