[英]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.