One, the realization clicks the button, duplicates the content in the text box
<script type= "Text/javascript" >
function copyUrl2 ()
{
var Url2=document.getelementbyid ("Biao1") ;
Url2.select (); Select the object
document.execcommand ("copy");///Execute Browser Copy command
alert ("copied well, sticky.") ");
}
</script>
<textarea cols= "rows=" id= "Biao1" > user-defined code area </textarea>
<input type= "Button" onclick= "CopyUrl2 ()" value= "click Copy Code"/>
Second, copy the topic address and URL address, passed to qq/msn friend
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
When you click the text box, copy the contents of the text box
<input onclick= "ocopy (This)" value= "hello. To copy the content!" >
<script language= "javascript" >
function ocopy (obj) {
obj.select ();
Js=obj.createtextrange ();
Js.execcommand ("copy")
alert ("Replication succeeded!");
</script>
V. Copy text boxes or hide the contents of a field
<script language= "javascript" >
function Copyurl (target) {
target.value=myimg.value;
Target.select ();
Js=myimg.createtextrange ();
Js.execcommand ("Copy");
Alert ("Copy succeeded!");
}
function addimg (target) {
target.value= "[img]" +myimg.value+ "[/img]";
Target.select ();
Js=target.createtextrange ();
Js.execcommand ("Copy");
Alert ("Copy succeeded!");
}
</script>
Vi. copying the contents of span tags
<script type= "Text/javascript" >
</script>
<br/>
<br/>
<script Type= "Text/javascript" >function copytext (obj)
{
var rng = Document.body.createTextRange ();
Rng.movetoelementtext (obj);
Rng.scrollintoview ();
Rng.select ();
Rng.execcommand ("Copy");
Rng.collapse (false);
Alert ("Copy succeeded!");
}
</script>
Seven, browser compatible CopyToClipboard ("Copy content")
function CopyToClipboard (TXT) {if (window.clipboarddata) {window.clipboardData.clearData ();
Clipboarddata.setdata ("Text", txt); Alert ("Copy succeeded!")
");
else if (navigator.userAgent.indexOf ("Opera")!=-1) {window.location = txt; else if (Window.netscape) {try {netscape.security.PrivilegeManager.enablePrivilege ("Universalxpconne
CT "); catch (E) {alert ("Rejected by browser!")
\ nplease type ' About:config ' in the browser address bar and enter \ n then set ' Signed.applets.codebase_principal_support ' to ' true '); var clip = components.classes[' @mozilla. Org/widget/clipboard;1 '].createinstance (Components.interfaces.nsIClipboa
RD);
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 ("Copy succeeded!")
"); }
}
Eight, compatible with the major browser replication code (combined with Zeroclipboard.js)