复制到剪切板
<div id="ios" style=";position: absolute;left:-200px; color: rgba(0,0,0,0);background-color: transparent" ></div>
function copyContent(string){ if(navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)){ window.getSelection().removeAllRanges(); var ios = document.getElementById("ios"); $('#ios').html(string); var range = document.createRange(); range.selectNode(ios); window.getSelection().addRange(range); document.execCommand('copy'); window.getSelection().removeAllRanges(); alert("复制成功"); }else{ var input = document.createElement('input'); input.value = string; document.body.appendChild(input); input.select(); document.execCommand("Copy"); input.className = 'inputClip'; input.style.display = 'none'; alert("复制成功"); } }