JS复制特定内容到粘贴板
时间:2021-01-21 10:53:58|栏目:ASP代码|点击: 次
<script language="javascript">
function readTxt()
{
alert(window.clipboardData.getData("text"));
}
function setTxt()
{
var t=document.getElementById("txt");
t.select();
window.clipboardData.setData('text',t.createTextRange().text);
}
</script>
<input name="txt" value="测试">
<input type="button" value="复制" onclick="setTxt()">
<input type="button" value="读取" onclick="readTxt()">
function readTxt()
{
alert(window.clipboardData.getData("text"));
}
function setTxt()
{
var t=document.getElementById("txt");
t.select();
window.clipboardData.setData('text',t.createTextRange().text);
}
</script>
<input name="txt" value="测试">
<input type="button" value="复制" onclick="setTxt()">
<input type="button" value="读取" onclick="readTxt()">