欧美一区二区三区性视频_婷婷综合另类小说色区_亚洲av乱码一区二区三区林ゆな_天堂在线资源中文在线8_久久这里只有精品首页

當(dāng)前位置: 首頁(yè) > 網(wǎng)站開(kāi)發(fā) > 正文

JS點(diǎn)擊復(fù)制鏈接代碼大全

妙網(wǎng)小編 發(fā)表于2016年3月25日 22:33

復(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>  

本文標(biāo)簽: 網(wǎng)站制作網(wǎng)站建設(shè)HTMLJS
本文標(biāo)題: JS點(diǎn)擊復(fù)制鏈接代碼大全
本文鏈接: http://parrion.com.cn/m/?post=541

隨機(jī)文章推薦 收藏本文

共有5985閱 / 0評(píng)我要評(píng)論
  1. 還沒(méi)有評(píng)論呢,快搶沙發(fā)~

發(fā)表你的評(píng)論吧返回頂部

!評(píng)論內(nèi)容需包含中文

請(qǐng)勾選本項(xiàng)再提交評(píng)論