3个回答
展开全部
<script type="text/javascript">
function jsCopy(){
var e=document.getElementById("contents");//对象是contents
e.select(); //选择对象
document.execCommand("Copy"); //执行浏览器复制命令
}
</script>
<textarea name="contents" cols="40" rows="5"></textarea>
<br />
<input type="button" onClick="jsCopy();" value="复制" />
function jsCopy(){
var e=document.getElementById("contents");//对象是contents
e.select(); //选择对象
document.execCommand("Copy"); //执行浏览器复制命令
}
</script>
<textarea name="contents" cols="40" rows="5"></textarea>
<br />
<input type="button" onClick="jsCopy();" value="复制" />
展开全部
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("window.status=''",1800)
}
}
//-->
</script>
2.将下面的代码复制到 <body>
<form name="test">
<a class="highlighttext" href="javascript:HighlightAll('test.select1')">Select All</a><br>
<textarea name="select1" rows=10 cols=35 >This is some text. This is some text. This is some text. This is some text.</textarea>
</form>
<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("window.status=''",1800)
}
}
//-->
</script>
2.将下面的代码复制到 <body>
<form name="test">
<a class="highlighttext" href="javascript:HighlightAll('test.select1')">Select All</a><br>
<textarea name="select1" rows=10 cols=35 >This is some text. This is some text. This is some text. This is some text.</textarea>
</form>
参考资料: http://www.itlearner.com/code/51js/0109.htm
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<script
type="text/javascript">
function
jsCopy(){
var
e=document.getElementById("contents");//对象是contents
e.select();
//选择对象
document.execCommand("Copy");
//执行浏览器复制命令
}
</script>
<textarea
name="contents"
cols="40"
rows="5"></textarea>
<br
/>
<input
type="button"
onClick="jsCopy();"
value="复制"
/>
type="text/javascript">
function
jsCopy(){
var
e=document.getElementById("contents");//对象是contents
e.select();
//选择对象
document.execCommand("Copy");
//执行浏览器复制命令
}
</script>
<textarea
name="contents"
cols="40"
rows="5"></textarea>
<br
/>
<input
type="button"
onClick="jsCopy();"
value="复制"
/>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询