JS replication features support for Ie/firefox/mozilla/ns_javascript tips

Source: Internet
Author: User
FF, does not support the replication function, to support the words, it is difficult
JS replication features support for Ie/firefox/mozilla/ns
The code is as follows:
Here are two ways:
<script language= "javascript" type= "Text/javascript" >/JS replication feature supports for Ie/firefox/mozilla/ns function Copy_clip ( Meintext) {if (window.clipboarddata) {window.clipboardData.setData ("Text", Meintext); 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.interfa ces.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.nsIS upportsstring); var Copytext=meintext; 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 the information below to the Clipboard: \ n" + meintext); return false; } function CopyToClipboard (TXT) {if (window.clipboarddata) {window.clipboardData.clearData (); Window.clipboardData.setData ("Text", txt); else if (navigator.userAgent.indexOf ("Opera")!=-1) {window.location = txt; else if (Window.netscape) {try {netscape.security.PrivilegeManager.enablePrivilege ("Univers Alxpconnect "); catch (E) {alert ("You use the FF browser, the copy function is rejected by the 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.nsIClip Board); 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); } var o= "JS replication feature support for Ie/firefox/mozilla/ns"; Alert ("The first way to copy the content is as follows: \ n" +o); Copy_clip (o); Alert ("The second way to copy the content is as follows: \ n" +o); CopyToClipboard (o); Alert ("Both tests, you look at the effect, find a place to paste it!" or write a Web page of their own to test the function! "); </script>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]

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.