Copy image to Clipboard not working in Firefox & Chrome

231 views
Skip to first unread message

Sajin Sasidharan

unread,
Apr 23, 2012, 8:53:40 AM4/23/12
to
I need one help regards JavaScript. I used this script in asp.net
website to copy image in an image control on button click.

<script type="text/javascript">
function CopyToClip() {
var imgControl =
document.getElementById('imageControlWithImageToCopy');
imgControl.contentEditable = 'true';
var controlRange;

if (document.body.createControlRange) {
controlRange = document.body.createControlRange();
controlRange.addElement(imgControl);
controlRange.execCommand('Copy');
}
imgControl.contentEditable = 'false';
return true;
}
</script>

This code for copying image (which is in an image control) to
clipboard and it works fine in IE.

But this script is not working in Firefox & Chrome.

Please suggest any good solution to work in Firefox & Chrome
Reply all
Reply to author
Forward
0 new messages