87,914
社区成员
发帖
与我相关
我的任务
分享
<html><head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script>
function $(id){return document.getElementById(id)}
function test(o,n,e){
if(n==0){
o.select();
o.style.backgroundColor='#0000FF';
o.style.color='#FFFFFF';
}
else{
e=e||window.event;
if (e.button==2){
var s=clipboardData.setData("Text",o.value);alert("已经复制了文本框内容:"+o.value)
}
}
}
</script>
</head>
<body>
<input type=text id='a' value='' onclick="test(this,0)" onmousedown='test(this,1,event)' />
一点这个input,该text中的文字全部被选中,背景变蓝,右键直接复制能把text里的文字都复制下来
</body></html>