【发布时间】:2016-08-15 15:28:45
【问题描述】:
能否请您指导我如何解决以下问题,或建议另一种复制到剪贴板的选项?
function click_to_copy_password(containerid) {
if (document.selection) {
var range = document.body.createTextRange();
range.moveToElementText(document.getElementById(containerid));
range.select();
} else if (window.getSelection) {
var range = document.createRange();
range.selectNode(document.getElementById(containerid));
window.getSelection().removeAllRanges();
window.getSelection().addRange(range);
}
document.execCommand('copy');
}
在 Chrome、Firefox 和 IE 中运行良好,但在 Safari 中无法运行。
【问题讨论】:
-
你好。欢迎来到堆栈溢出。请环顾四周并拨打tour,并阅读[帮助中心]。您还可以阅读How to Ask 一个好问题。
标签: javascript safari clipboard