is it possible to copy a string to the clipboard using firefox like it is with IE?
I think I read somewhere that it is, but you don't use the same object.
any ideas?
copy to clipboard in firefox
Moderator: General Moderators
- Buddha443556
- Forum Regular
- Posts: 873
- Joined: Fri Mar 19, 2004 1:51 pm
There's an xulplanet.com's tutorial for Using the Clipboard. However, you'll get a 'Permission denied to get property UnnamedClass.classes' error. You'll have to use signed code or install some chrome. Might want to look into netscape.security.PrivilegeManager.enablePrivilege() and file://.
Here's something on Signed Scripts in Mozilla.
Here's something on Signed Scripts in Mozilla.
this is what I came up with after doing a little more research.
to make this work, I had to change a security setting in FF on about:config
I had to change (signed.applets.codebase_principal_support) to true. Now it prompts me and asks if I want to allow it...since all of these will be run on my own sites, I accepted and I'm now a happy man
Code: Select all
<script language="javascript" type="text/javascript">
<!--
function copy_clip(thetext)
{
if (window.clipboardData)
{
window.clipboardData.setData("Text", thetext);
}
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=thetext;
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;
}
//-->
</script>
I had to change (signed.applets.codebase_principal_support) to true. Now it prompts me and asks if I want to allow it...since all of these will be run on my own sites, I accepted and I'm now a happy man
