Моя проблема исправлена:
Вот сценарий: этот сценарий копирует весь текст из текстового поля, и вы можете вставить его в любом месте браузера Firefox.
<!-- Following script is for copy & paste function -->
<script>
<![CDATA[
function copyToClipboard() {
//Select all the text/strings from the textbox.
var copytext=document.getElementById('tb').value;
//alert(document.getElementById('tb').value + 'This is XUL');
//An XPCOM wrapper for the data which you want to put on the clipboard.
var str = Components.classes["@mozilla.org/supports-string;1"].
createInstance(Components.interfaces.nsISupportsString);
if (!str) return false;
str.data = copytext;
//This object is the component @mozilla.org/widget/transferable;1 which implements the interface nsITransferable.
var trans = Components.classes["@mozilla.org/widget/transferable;1"].
createInstance(Components.interfaces.nsITransferable);
if (!trans) return false;
trans.addDataFlavor("text/unicode");
trans.setTransferData("text/unicode", str, copytext.length * 2);
var clipid = Components.interfaces.nsIClipboard;
var clip = Components.classes["@mozilla.org/widget/clipboard;1"].getService(clipid);
if (!clip) return false;
clip.setData(trans, null, clipid.kGlobalClipboard);
//alert(document.getElementById('tb').value + 'This is fuckin XUL');
pasteFromClip();
window.close();
}
function pasteFromClip() {
var clip = Components.classes["@mozilla.org/widget/clipboard;1"].getService(Components.interfaces.nsIClipboard);
if (!clip) return false;
var trans = Components.classes["@mozilla.org/widget/transferable;1"].createInstance(Components.interfaces.nsITransferable);
if (!trans) return false;
trans.addDataFlavor("text/unicode");
clip.getData(trans, clip.kGlobalClipboard);
var str = new Object();
var len = new Object();
trans.getTransferData("text/unicode",str,len);
str = str.value.QueryInterface(Components.interfaces.nsISupportsString);
str = str.data.substring(0, len.value / 2);
return document.createTextNode(str);
}
]]>
</script>