How to copy text to clipboard in Firefox 3.5?

How can you copy text to the clipboard using Javascript (or even better use the jQuery function) without Flash being involved ?

I do not need IE and other browsers; Firefox 3.5 is the only browser that matters to change local FF settings in order.

Edit : Sorry for not understanding, I tried the first 30 methods that I found through Google; none of them worked for me.

+1
source share
4 answers

A simple Google search resulted in:

0

firefox . firefox, :

firefox : "about: config" ( ) enter.

"", , "", . . , ENABLED. . on, firefox , - , " .... "

0

, , JavaScript.

  • Firefox, .

- ( Mozilla):

function copyToClipboard(text) {

// ask for permission to access clipboard

try {
    netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
} catch(e) {
    alert("Clipboard copying is not allowed. Set signed.applets.codebase_principal_support to 'true' in Mozilla Firefox.");
    return false;
}

// make a copy of the Unicode

var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
if (!str) return false; // couldn't get string obj
str.data = text; // unicode string?


// add Unicode & HTML flavors to the transferable widget

var trans = Components.classes["@mozilla.org/widget/transferable;1"].createInstance(Components.interfaces.nsITransferable);
if (!trans) return false; //no transferable widget found

trans.addDataFlavor("text/unicode");
trans.setTransferData("text/unicode", str, text.length * 2); // *2 because it unicode 


// copy the transferable widget!

var clipboard = Components.classes["@mozilla.org/widget/clipboard;1"].getService(Components.interfaces.nsIClipboard);
if (!clipboard) return false; // couldn't get the clipboard

clipboard.setData(trans, null, Components.interfaces.nsIClipboard.kGlobalClipboard);
return true;

}
0

Source: https://habr.com/ru/post/1768371/


All Articles