Javascript 不使用 Flash 复制到剪贴板 - Firefox、Chrome、Safari、Opera

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8742559/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 07:17:59  来源:igfitidea点击:

Copy to clipboard with no Flash - Firefox, Chrome, Safari, Opera

javascriptjqueryclipboard

提问by pinus.acer

Possible Duplicate:
Copy to clipboard without Flash

可能的重复:
在没有 Flash 的情况下复制到剪贴板

I want to copy some text from an element by a given id to clipboard. I want to be flashlesssolution, no Flash at all. It can be in jQuery or JavaScript.

我想通过给定的 id 将元素中的一些文本复制到剪贴板。我想成为闪存解决方案,根本没有闪存。它可以是 jQuery 或 JavaScript。

The solution for IE is simple (clipboardData), but for FF, Chrome and others - it doesn't work.

IE 的解决方案很简单 (clipboardData),但对于 FF、Chrome 和其他人 - 它不起作用。

Help.

帮助。

回答by Manse

There is no javascript method to do this - its prevented by browser security ... Flash is the best alternative ...

没有 javascript 方法可以做到这一点 - 它被浏览器安全所阻止...... Flash 是最好的选择......

Explanation of security policy on Firefox -> http://kb.mozillazine.org/Granting_JavaScript_access_to_the_clipboard

Firefox 安全策略说明 -> http://kb.mozillazine.org/Granting_JavaScript_access_to_the_clipboard