Boaz

js复制到剪切板
/**复制内容到粘贴板content : 需要复制的内容message : 复制完后的提示,不传则默认提示"复制成...
扫描右侧二维码阅读全文
13
2020/10

js复制到剪切板

/**

  • 复制内容到粘贴板
  • content : 需要复制的内容
  • message : 复制完后的提示,不传则默认提示"复制成功"
    */

function copyToClip(content, message) {

var aux = document.createElement("input"); 
aux.setAttribute("value", content); 
document.body.appendChild(aux); 
aux.select();
document.execCommand("copy"); 
document.body.removeChild(aux);
if (message == null) {
    alert("复制成功");
} else{
    alert(message);
}

}

Last modification:October 23rd, 2020 at 09:55 am
If you think my article is useful to you, please feel free to appreciate

Leave a Comment