JavaScript Copying to clipboard? Disabled?
I use a few sites that add a handy tool that copys text to my clipboard
This is the script they use:
PHP Code:
function toclip(cmd) {
if (window.clipboardData) {
window.clipboardData.setData('Text', cmd);
} else if (window.netscape) {
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
if (!str)
return;
str.data = cmd;
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');
trans.setTransferData('text/unicode',str,cmd.length*2);
var clipid = Components.interfaces.nsIClipboard;
clip.setData(trans,null,clipid.kGlobalClipboard);
}
return false;
}
I am using Firefox 1.0 and IE 6.0 (XP SP2) and this function does not work on both. I think it may have something to do w/ sp2 because this is a pretty fresh install (1.5months)
I didnt, just notice it... it has been hapening for a while... just been too lazy to do anything about it.
Any ideas?
Re: JavaScript Copying to clipboard? Disabled?
Firefox has a plug in that copies text directly from a webpage into memory. My visually impaired friend just got it for his screen reading program. I'll have to check with him to see if it worked. He has SP2.
Re: JavaScript Copying to clipboard? Disabled?
This is a security feature in Firefox. The script must be signed or you must set the value "signed.applets.codebase_principal_support" in about:config true.