欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

用 javascript 實現(xiàn)的點擊復制代碼

 更新時間:2007年03月24日 00:00:00   投稿:mdxy-dxy  
用 javascript 實現(xiàn)的點擊復制代碼,需要的朋友可以參考一下

最常用的代碼,不需要多瀏覽器都兼容,但代碼比較簡潔,也不用很多的js與flash

function copyToClipboard(txt) {  
	if(window.clipboardData){  
		window.clipboardData.clearData();  
		window.clipboardData.setData("Text", txt);
		alert('復制成功!')
	}else{
		alert('請手動復制!')	
	}  
}

如果你需要這個兼容多瀏覽器的js復制代碼功能可以參考這篇文章:

http://www.dbjr.com.cn/article/76769.htm

<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的內(nèi)容!">
 
<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.dbjr.com.cn" /> 
<input name=imgurl type=text size=32 value="http://www.dbjr.com.cn" /> 
<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.dbjr.com.cn</span>
[<a href="#" onclick="copyText(document.all.tbid)">點擊復制</a>]<br/><br/>
<span id="tbid2">http://www.dbjr.com.cn</span>
[<a href="#" onclick="copyText(document.all.tbid2)">點擊復制</a>]<br/><br/>

相關文章

最新評論