[英]document.execCommand('copy') Command not working in Chrome
[英]document.execCommand copy command does not work or other solution?
我正在做的是以编程方式从网页中选择所有文本然后复制它。 select all适用于execCommand
但复制不适用。
这是我的代码:
$.ajax({
url: $('#url').val(),
type: 'GET',
success: function(res) {
$('#result').html(res.responseText);
$('#result').fadeIn('fast');
$('#result').focus();
$('#result').select();
document.execCommand('selectall');
// copy does not work ?
document.execCommand('copy');
}
});
我也试过使用诸如ZeroClipboard之类的 flash解决方案,但似乎必须明确地按下他们的flash对象/按钮来复制文本,而我想做zeroclip.setText('whatever');
没有用户按下按钮。
任何人都可以告诉如何以编程方式复制文本?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.