My from submission is returning a block of text that i would like sent directly to the system's clipboard. Users are on FF3.6x thx
A:
Hi you can use following function:
function copy_to_clipboard(text)
{
if(window.clipboardData)
{
window.clipboardData.setData('text',text);
}
else
{
var clipboarddiv=document.getElementById('divclipboardswf');
if(clipboarddiv==null)
{
clipboarddiv=document.createElement('div');
clipboarddiv.setAttribute("name", "divclipboardswf");
clipboarddiv.setAttribute("id", "divclipboardswf");
document.body.appendChild(clipboarddiv);
}
clipboarddiv.innerHTML='<embed src="clipboard.swf" FlashVars="clipboard='+
encodeURIComponent(text)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';
}
alert('The text is copied to your clipboard...');
return false;
}
Further info: http://stackoverflow.com/questions/400212/how-to-copy-to-clipboard-in-javascript/400266#400266
and thanks to Andreas Grech
infinity
2010-10-02 12:05:07
Let me know if I'm missing something, it looks like this approach is pretty much deprecated by Flash 10. GvS poins @GvS for http://code.google.com/p/zeroclipboard/
justSteve
2010-10-02 17:02:24