<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>Comments on snippet: 'javascript copy text to clipborad'</title>
<link>http://snipplr.com</link>
<description>Snipplr comments feed'</description>
<language>en-us</language>
<pubDate>Thu, 20 Jun 2013 07:25:29 GMT</pubDate>
<item>
<title>sergiozoumenou said on 6/24/09</title>
<link>http://snipplr.com/view/6450/javascript-copy-text-to-clipborad/</link>
<description><![CDATA[ hi thanks for the code .i ma using the code below to copy to clipboard in mozilla and have a buton that call the fuction to copy. how can i paste in a field with a button that will call a fucntion like "fonction pastefromclipborad (aaaa).

My code :


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.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=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);

}

return false;
}
//--> ]]></description>
<pubDate>Wed, 24 Jun 2009 16:42:25 GMT</pubDate>
<guid>http://snipplr.com/view/6450/javascript-copy-text-to-clipborad/</guid>
</item>
<item>
<title>sergiozoumenou said on 6/24/09</title>
<link>http://snipplr.com/view/6450/javascript-copy-text-to-clipborad/</link>
<description><![CDATA[ hi thanks for the code .i ma using the code below to copy to clipboard in mozilla and have a buton that call the fuction to copy. how can i paste in a field with a button that will call a fucntion like "fonction pastefromclipborad (aaaa).

My code :


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.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=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);

}

return false;
}
//--> ]]></description>
<pubDate>Wed, 24 Jun 2009 16:36:44 GMT</pubDate>
<guid>http://snipplr.com/view/6450/javascript-copy-text-to-clipborad/</guid>
</item>
</channel>
</rss>