[英]Safari browser doesn't support document.execCommand('copy'); command?
Can you please guide me on how to fix following issue, or suggest another option for copying to the clipboard? 您能指导我如何解决以下问题,或建议另一种选择复制到剪贴板吗?
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');
}
It's working fine in Chrome, Firefox & IE, but it does not work in Safari. 在Chrome,Firefox和IE中可以正常工作,但在Safari中则无法工作。
目前,Safari不支持execCommand('copy')
API,但在Safari 10中将有所变化: https : //developer.apple.com/library/archive/releasenotes/General/WhatsNewInSafari/Articles/Safari_10_0.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.