|
-
Feb 22nd, 2005, 09:18 PM
#1
Thread Starter
Frenzied Member
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?
Last edited by <ABX; Mar 10th, 2005 at 01:52 PM.
Tips:
- Google is your friend! Search before posting!
- Name your thread appropriately... "I Need Help" doesn't cut it!
- Always post your code!!!! We can't read your mind!!! (well, at least most of us!)
- Allways Include the Name and Line of the Exception (if one is occuring!)
- If it is relevant state the version of Visual Studio/.Net Framwork you are using (2002/2003/2005)
If you think I was helpful, rate my post  IRC Contact: Rizon/xous ChakraNET/xous Freenode/xous
-
Feb 23rd, 2005, 03:02 AM
#2
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.
-
Mar 10th, 2005, 01:50 PM
#3
Thread Starter
Frenzied Member
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.
Tips:
- Google is your friend! Search before posting!
- Name your thread appropriately... "I Need Help" doesn't cut it!
- Always post your code!!!! We can't read your mind!!! (well, at least most of us!)
- Allways Include the Name and Line of the Exception (if one is occuring!)
- If it is relevant state the version of Visual Studio/.Net Framwork you are using (2002/2003/2005)
If you think I was helpful, rate my post  IRC Contact: Rizon/xous ChakraNET/xous Freenode/xous
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|