表單提交時自動復(fù)制內(nèi)容到剪貼板的js代碼
更新時間:2007年03月16日 00:00:00 作者:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>交時自動復(fù)制到剪貼板</title>
</head>
<script language="JavaScript">
/*功能:提交時自動復(fù)制到剪貼板 */
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" />
提交時復(fù)制內(nèi)容到剪貼板<br/><input type="submit" value="提交" /> </form>
</body>
</html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>交時自動復(fù)制到剪貼板</title>
</head>
<script language="JavaScript">
/*功能:提交時自動復(fù)制到剪貼板 */
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" />
提交時復(fù)制內(nèi)容到剪貼板<br/><input type="submit" value="提交" /> </form>
</body>
</html>
相關(guān)文章
ES6新數(shù)據(jù)結(jié)構(gòu)Map功能與用法示例
這篇文章主要介紹了ES6新數(shù)據(jù)結(jié)構(gòu)Map功能與用法,結(jié)合實(shí)例形式分析了Map的功能、使用方法及相關(guān)注意事項(xiàng),需要的朋友可以參考下2017-03-03
JS+Canvas實(shí)現(xiàn)動態(tài)時鐘效果
這篇文章主要為大家詳細(xì)介紹了JS+Canvas實(shí)現(xiàn)動態(tài)時鐘效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下2021-10-10
原生js仿jquery實(shí)現(xiàn)對Ajax的封裝
大家都知道jquery在我們?nèi)粘i_發(fā)中的使用頻率非常高,但jquery說到底還是對js的封裝,我們不能光會使用,只有知道了其中的遠(yuǎn)離才能更好的使用,所以這篇文章主要介紹的是原生js仿jquery實(shí)現(xiàn)對Ajax封裝的方法。2016-10-10
JavaScript使用二分查找算法在數(shù)組中查找數(shù)據(jù)的方法
這篇文章主要介紹了JavaScript使用二分查找算法在數(shù)組中查找數(shù)據(jù)的方法,較為詳細(xì)的分析了二分查找法的原理與javascript實(shí)現(xiàn)技巧,需要的朋友可以參考下2015-04-04

