方法1:
var oInput = document.getElementById('input'); oInput.select(); // 選擇對(duì)象 document.execCommand("Copy"); // 執(zhí)行瀏覽器復(fù)制命令 message.success("復(fù)制成功", 1);
方法2:
var dummy = document.createElement('input'); text = window.location.href; document.body.AppendChild(dummy); dummy.value = text; dummy.select(); // 選擇對(duì)象 document.execCommand('copy'); // 執(zhí)行瀏覽器復(fù)制命令 document.body.removeChild(dummy);