JavaScript 使用execCommand(“ copy”)从textarea复制到剪贴板
示例
例:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<textarea id="content"></textarea>
<input type="button" id="copyID" value="Copy" />
<script type="text/javascript">
var button = document.getElementById("copyID"),
input = document.getElementById("content");
button.addEventListener("click", function(event) {
event.preventDefault();
input.select();
document.execCommand("copy");
});
</script>
</body>
</html>document.execCommand("copy")将当前选择复制到剪贴板
热门推荐
5 足球队祝福语简短
10 大雪生日祝福语大全简短
11 英语简短祝福语给学生
12 生日祝福语大全女孩简短
13 领证幽默祝福语简短
14 大学报道祝福语简短
15 婆婆生日祝福语短语简短
16 男朋友祝福语简短新年
17 今日祝福语简短10字
18 许嵩生日祝福语简短