18

I need to copy an image to clipboard using JavaScript/jquery and I am using the following js to achieve that.

function copyImageToClipBoard() {
            var div = document.getElementById('chart1');
            div.contentEditable = true;
            var controlRange;
            if (document.body.createControlRange) {
                controlRange = document.body.createControlRange();
                controlRange.addElement(div);
                controlRange.execCommand('Copy');                   
            }
            div.contentEditable = false;
        }

It works fine locally in IE. But when I tried to test it from other machines IE, to paste the image into MS word I need to use the Paste Special-> Device Independent Bitmap option, otherwise I cannot see the image pasted.

I was wondering if it has anything to do with the environment of the m/c. If so is there any other option which works anywhere?

AstroCB
  • 12,337
  • 20
  • 57
  • 73
kranthi
  • 1,519
  • 6
  • 29
  • 52

1 Answers1

-3

Clipboard access on the web is not desirable because of the security implications.

rburk
  • 101
  • 2
  • 12