//单独复制
function copyUrl(id) {
var url = document.getElementById("fix_"+id).innerText;
var input = document.createElement('input');
input.value = url;
document.body.appendChild(input)
input.select();
document.execCommand("Copy");
input.className="oInput";
input.style.display = 'none';
}
//批量复制
function copyUrlPatch(){
var divs = document.getElementsByClassName("fix");
var urls = '';
for(var i=0;i<divs.length;i++){
var url = divs[i].innerText;
if(url){
urls=urls+url+"\r\n";
}
}
console.log(urls)
var textArea = document.createElement("textarea");
textArea.style.position = 'fixed';
textArea.style.top = '0';
textArea.style.left = '0';
textArea.style.width = '2em';
textArea.style.height = '2em';
textArea.style.padding = '0';
textArea.style.border = 'none';
textArea.style.outline = 'none';
textArea.style.boxShadow = 'none';
textArea.style.background = 'transparent';
textArea.value = urls;
document.body.appendChild(textArea);
textArea.select();
try {
var successful = document.execCommand('copy');
var msg = successful ? '成功复制到剪贴板' : '该浏览器不支持点击复制到剪贴板';
alert(msg);
} catch (err) {
alert('该浏览器不支持点击复制到剪贴板');
}
document.body.removeChild(textArea);
}