复制内容到剪切板,兼容移动端

function copyText(d) {
    var c = document.createElement("textarea");
    c.style.position = "absolute";
    c.style.left = "-9999px";
    c.style.bottom = "0";
    document.body.appendChild(c);
    c.textContent = d;
    c.focus();
    c.setSelectionRange(0, c.value.length);
    var a;
    try {
        a = document.execCommand("copy")
    } catch(b) {
        a = false
    }
    document.body.removeChild(c);
    return a
}

 uc不得行

原文地址:https://www.cnblogs.com/yghgo/p/6801370.html