Results 1 to 3 of 3

Thread: JavaScript Copying to clipboard? Disabled?

Threaded View

  1. #1

    Thread Starter
    Frenzied Member <ABX's Avatar
    Join Date
    Jul 2002
    Location
    Canada eh...
    Posts
    1,622

    Resolved 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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width