表單提交時自動復制內(nèi)容到剪貼板的js代碼
更新時間:2007年03月16日 00:00:00 作者:
<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" />
提交時復制內(nèi)容到剪貼板<br/><input type="submit" value="提交" /> </form>
</body>
</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" />
提交時復制內(nèi)容到剪貼板<br/><input type="submit" value="提交" /> </form>
</body>
</html>
相關(guān)文章
javascript中eval和with用法實例總結(jié)
這篇文章主要介紹了javascript中eval和with用法,結(jié)合實例形式總結(jié)分析了JavaScript中eval和with的功能、用法與相關(guān)注意事項,具有一定參考借鑒價值,需要的朋友可以參考下2015-11-11