萬盛學電腦網

 萬盛學電腦網 >> 網絡編程 >> php編程 >> 表單提交時自動復制內容到剪貼板

表單提交時自動復制內容到剪貼板

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>交時自動復制到剪貼板</title>
</head>

<script language="JavaScript">
/*功能:提交時自動復制到剪貼板 */

function copyText(obj) {
ie = (document.all)? true:false
if (ie){
var rng = document.body.createTextRange();
rng.moveToElementText(obj);
rng.scrollIntoView();
rng.select();
rng.execCommand("Copy");
rng.collapse(false);
}
}

function autocopy() {
if (this.document.formname.isautocopy.checked) {
copyText(this.document.formname.icontent);
}
}
</script>

<body>
<form action=""  method="post" name="formname" onsubmit="autocopy();">
<textarea name="icontent" rows="4" cols="50"></textarea><br>
<input name="isautocopy" checked="checked" value="1" type="checkbox" />
提交時復制內容到剪貼板<br/><input type="submit" value="提交" /> </form>

</body>
</html>

copyright © 萬盛學電腦網 all rights reserved