復(fù)制專(zhuān)題地址和url地址,傳給QQ/MSN上的好友
<input type="button" name="anniu1"
onClick='copyToClipBoard()' value="復(fù)制專(zhuān)題地址和url地址,傳給QQ/MSN上的好友">
<script
language="javascript">
function copyToClipBoard(){
var
clipBoardContent="";
clipBoardContent+=document.title;
clipBoardContent+="";
clipBoardContent+=this.location.href;
window.clipboardData.setData("Text",clipBoardContent);
alert("復(fù)制成功,請(qǐng)粘貼到你的QQ/MSN上推薦給你的好友");
}
</script>
直接復(fù)制url
<input
type="button" name="anniu2" onClick='copyUrl()'
value="復(fù)制URL地址">
<script language="javascript">
function
copyUrl()
{
var
clipBoardContent=this.location.href;
window.clipboardData.setData("Text",clipBoardContent);
alert("復(fù)制成功!");
}
</script>
點(diǎn)擊文本框時(shí),復(fù)制文本框里面的內(nèi)容
<input
onclick="oCopy(this)" value="你好.要copy的內(nèi)容!">
<script
language="javascript">
function
oCopy(obj){
obj.select();
js=obj.createTextRange();
js.execCommand("Copy")
alert("復(fù)制成功!");
}
</script>
復(fù)制文本框或者隱藏域中的內(nèi)容
<script
language="javascript">
function
CopyUrl(target){
target.value=myimg.value;
target.select();
js=myimg.createTextRange();
js.execCommand("Copy");
alert("復(fù)制成功!");
}
function
AddImg(target){
target.value="[IMG]"+myimg.value+"[/
img]";
target.select();
js=target.createTextRange();
js.execCommand("Copy");
alert("復(fù)制成功!");
}
</script>
其它代碼:
<input
name=myimg type=hidden id=myimg value="http://。。。.com/" />
<input
name=imgurl type=text size=32 value="http://。。。.com/" />
<input
type=button value="點(diǎn)擊這里復(fù)制本站地址" onclick="CopyUrl(imgurl);"
/>
復(fù)制span標(biāo)記中的內(nèi)容
<script
type="text/javascript">
</script>
<br />
<br
/>
<script type="text/javascript">function copyText(obj)
{
var
rng =
document.body.createTextRange();
rng.moveToElementText(obj);
rng.scrollIntoView();
rng.select();
rng.execCommand("Copy");
rng.collapse(false);
alert("復(fù)制成功!");
}
</script>
以下是代碼片段
<span
id="tbid">http://。。。.com/</span>
[<a href="#"
onclick="copyText(document.all.tbid)">點(diǎn)擊復(fù)制</a>]<br/><br/>
<span
id="tbid2">http://。。。.com/</span>
[<a href="#"
onclick="copyText(document.all.tbid2)">點(diǎn)擊復(fù)制</a>]<br/><br/>
</p>
</body>
</html>
另加一個(gè)常見(jiàn)的:
<input type="text" size="30" id="url" value="http://。。。.com/"> <input type="button" value="復(fù)制鏈接"
onClick="copyUrl()">
<script type="text/javascript">
function copyUrl(){
var url = document.getElementById("url").value;
window.clipboardData.setData("Text",url);
alert("復(fù)制鏈接成功!");
}
</script>
!評(píng)論內(nèi)容需包含中文