将图像复制到剪贴板不能在Firefox中使用&铬 [英] Copy image to Clipboard not working in Firefox & Chrome

查看:101
本文介绍了将图像复制到剪贴板不能在Firefox中使用&铬的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

Possible Duplicate:
How to copy to the clipboard in JavaScript?

我需要一个关于JavaScript的帮助。我在asp.net网站上使用了这个脚本。

I need one help regards JavaScript. I used this script in asp.net website.

    <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>

此代码用于将图像(在图像控件中)复制到剪贴板并在IE中正常工作。

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

但是这个脚本不适用于Firefox& Chrome。

But this script is not working in Firefox & Chrome.

请提出任何适用于Firefox和Firefox的解决方案。 Chrome

Please suggest any good solution to work in Firefox & Chrome

推荐答案

抱歉,您无法在Chrome或Firefox中将内容复制到剪贴板中。 Internet Explorer有一个小漏洞,可以让你这样做,但它几乎是唯一支持这种功能的浏览器。

Sorry, but you can't copy stuff into the clipboard in Chrome or Firefox. Internet Explorer has a small hole that lets you do this, but it's the pretty much the only browser that supports that type of functionality any more.

有一个 Flash hack 使这成为可能,但那只是文字,对不起。

There's a Flash hack to make this possible, but that's only for text, sorry.

这篇关于将图像复制到剪贴板不能在Firefox中使用&amp;铬的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆