This function of copying text and then CTRL + V operation looks like JQ also has no encapsulation ...

Source: Internet
Author: User

/** Copy*/functioncopy () {varmaintext=$ ("#myhtml"). Val ();        alert (maintext);    CopyToClipboard (Maintext); }functionCopyToClipboard (maintext) {if(window.clipboarddata) {Window.clipboardData.setData ("Text", Maintext); }Else if(window.netscape) {Try{Netscape.security.PrivilegeManager.enablePrivilege ("Universalxpconnect"); }Catch(e) {alert ("The browser does not support one-click Replication!" Please copy the content manually "); }        varClip = components.classes[' @mozilla. Org/widget/clipboard;1 '].createinstance (Components.interfaces.nsIClipboard); if(!clip)return; vartrans = Components.classes[' @mozilla. Org/widget/transferable;1 '].createinstance (Components.interfaces.nsITransferable); if(!trans)return; Trans.adddataflavor (' Text/unicode '); varstr =NewObject (); varLen =NewObject (); varstr = components.classes["@mozilla. Org/supports-string;1"].createinstance (Components.interfaces.nsISupportsString); varcopytext=Maintext; Str.data=CopyText; Trans.settransferdata ("Text/unicode", str,copytext.length*2); varClipid=Components.interfaces.nsIClipboard; if(!clip)return false; Clip.setdata (trans,NULL, Clipid.kglobalclipboard); } alert ("The following content has been copied to the Clipboard nn" +maintext); }

This function of copying text and then CTRL + V operation looks like JQ also has no encapsulation ...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.