<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>
自动
表单提交
表单
剪贴板
js代码
js