怎么将网页中指定文本框的内容复制到剪贴板

来源:百度知道 编辑:UC知道 时间:2024/06/08 13:50:17
怎么将网页中指定文本框的内容复制到剪贴板
asp/js代码都可以

1.将下面的代码复制到 <head>
<style>
.highlighttext{
background-color:yellow;
font-weight:bold;
}
</style>

<script language="Javascript">
<!--

/*
Highlight and Copy form element script- By Dynamicdrive.com
For full source, Terms of service, and 100s DTHML scripts
Visit http://www.dynamicdrive.com
*/

//specify whether contents should be auto copied to clipboard (memory)
//Applies only to IE 4+
//0=no, 1=yes
var copytoclip=1

function HighlightAll(theField) {
var tempval=eval("document."+theField)
tempval.focus()
tempval.select()
if (document.all&©toclip==1){
therange=tempval.createTextRange()
therange.execCommand("Copy")
window.status="Contents highlighted and copied to clipboard!"
setTimeout(