使用JavaScript / jquery将图像复制到剪贴板 [英] Copying an image to clipboard using JavaScript/jquery
问题描述
我需要使用JavaScript / jquery将图像复制到剪贴板,我使用以下j来实现这一点。
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;
}
它在IE中本地工作正常。但是当我试图从其他机器上测试IE时,要将图像粘贴到MS字中,我需要使用Paste Special-> Device Independent Bitmap选项,否则我看不到粘贴的图像。
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.
我想知道它是否与m / c的环境有关。如果是这样,还有其他选项可以在任何地方使用吗?
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?
推荐答案
由于安全隐患,网页上的剪贴板访问是不可取的。
Clipboard access on the web is not desirable because of the security implications.
这篇关于使用JavaScript / jquery将图像复制到剪贴板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!