1.ZeroClipboard
2.execCommand
A. JSP页面
<div id="inputAddDiv" style="display:none"><input id="inputAdd" /></div>
B. JS
//拷贝文本到剪切板
TaskApp.copyToClipBord = function(_text){
$("#inputAddDiv").show();
$("#inputAdd").val(_text);
var inputAdd = $("#inputAdd");
inputAdd.select();
document.execCommand("Copy");
$("#inputAddDiv").hide();
$.messager.show({
msg:'复制成功!',
timeout:3000,
showType:'fade',
style:{
top:document.body.scrollTop+document.documentElement.scrollTop,
padding:'0',
height:'30px'
}
});
}