表单提交时自动复制内容到剪贴板
作者/sunnie 时间/2007-1-10 17:23:00 类别/知识积累 查看/
 发表评论 以论坛方式查看
标签:综合 娱乐 Design 知识积累
<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>

今天在网络上发现了这个小东西,这功能虽然非常小,但有时候却非常有用。
估计你也有过这种经历:长篇大论后提交,发现"该页无法显示",或者"登录超时"...

然后,你不得不捶桌子?哈哈


如何在页面里加入,就看你自己的了,会html的都会的
查看该用户更多文章>>