<title>標題</title>
<input type="button" name="Submit" onClick='copyToClipBoard()' value="複製專題地址,傳給QQ/MSN上的好友">
<script language="javascript">
function copyToClipBoard(){
var clipBoardContent="";
clipBoardContent+=document.title;
clipBoardContent+="";
clipBoardContent+=this.location.href;
window.clipboardData.setData("Text",clipBoardContent);
alert("複製成功,請粘貼到你的QQ/MSN上推薦給你的好友");
}
</script>
<script>
function oCopy(obj){
obj.select();
js=obj.createTextRange();
js.execCommand("Copy")
}
</script>
<input onclick="oCopy(this)" value="要copy的內容!">
<script language="javascript">
function CopyUrl(target){
target.value=myimg.value;
target.select();
js=myimg.createTextRange();
js.execCommand("Copy");
}
function AddImg(target){
target.value="[IMG]"+myimg.value+"[/ img]"; (註:[/ img]中/後面有空格請去掉 )
target.select();
js=target.createTextRange();
js.execCommand("Copy");
}
</script>
<input name=myimg type=hidden id=myimg value="http://www.jb51.net" />
<input name=imgurl type=text size=32 value="http://www.jb51.net" />
<input type=button value="點擊這裡複製本站地址" onclick="CopyUrl(imgurl);" />
<P>如果你喜歡本站,就推薦給你的朋友吧!</P>
<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);}
</script>
以下是程式碼片段:
複製代碼 代碼如下:
<span id="tbid">http://www.jb51.net</span>
[<a href="#" onclick="copyText(document.all.tbid)">點擊複製</a>]<br/><br/>
<span id="tbid2">http://www.jb51.net</span>
[<a href="#" onclick="copyText(document.all.tbid2)">點擊複製</a>]<br/><br/>