Copy and paste the JS code (IE/FIREFOX/MOZILLA/NS)

Source: Internet
Author: User
Tags config

JScript Some of the properties are actually very good, but it is only IE support, such as copying and pasting properties

The following section of the copied and pasted JavaScript code can support Ie/firefox/mozilla/ns, the foreigner site appears to

Just need to modify the About:config in Firefox under a property

<script language= "javascript" type= "Text/javascript" >
<!--
function Copy_clip (meintext)
{
if (Window.clipboarddata)
{

The Ie-manier
Window.clipboardData.setData ("Text", Meintext);

Waarschijnlijk niet de beste manier om moz/ns te detecteren;
Het is mij echter onbekend vanaf welke versie dit precies Werkt:
}
else if (window.netscape)
{

The DIT is Belangrijk maar staat nergens Duidelijk Vermeld:
You are have to sign the code to enable this, or the notes below
Netscape.security.PrivilegeManager.enablePrivilege (' Universalxpconnect ');

Maak een interface naar het clipboard
var clip = components.classes[' @mozilla. Org/widget/clipboard;1 ']
. CreateInstance (Components.interfaces.nsIClipboard);
if (!clip) return;

Maak een transferable
var trans = components.classes[' @mozilla. Org/widget/transferable;1 ']
. CreateInstance (Components.interfaces.nsITransferable);
if (!trans) return;

Specificeer Wat voor soort data we op Willen Halen; Text in dit Geval
Trans.adddataflavor (' Text/unicode ');

Om de data uit de transferable te Halen hebben we 2 Nieuwe Objecten
Nodig om het in op te slaan
var str = new Object ();
var len = new Object ();

var str = components.classes["@mozilla. Org/supports-string;1"]
. CreateInstance (Components.interfaces.nsISupportsString);

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 ("Following info is copied to your clipboard:\n\n" + meintext);
return false;
}
-->
</script>

Notes about security:

A cause of the tight security settings in Mozilla/have to sign the JavaScript to make it work another way are to Your Firefox/mozilla settings

To does this add this line to your prefs.js file in your Firefox/mozilla user profile directory

User_pref ("Signed.applets.codebase_principal_support", true);

or change it from within the browser with calling the "About:config" page

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.