小弟在这里求一段JS代码   
就是我有一个文本框  旁边有一个复制按钮,按一下那个复制按钮,就把文本框里的内容给复制下来,最好还弹出提示,复制成功。谢谢 

解决方案 »

  1.   

    <script language="javascript"> 
       function copyToClipBoard(){ 
        var clipBoardContent=""; 
        clipBoardContent+=document.title; 
        clipBoardContent+=""; 
        clipBoardContent+=this.location.href; 
        window.clipboardData.setData("Text",clipBoardContent); 
        alert("Copy the success, please paste it into your MSN on the recommendation of a friend to you"); 
      } 
      </script>
      

  2.   


     <script>
            var text = "";
            function CopyText() {
                document.getElementById("Text1").select();
                text = document.getElementById("Text1").value;
                alert("复制成功!");
            }
            function PasteText() {
                document.getElementById("Text2").focus();
                document.getElementById("Text2").value = text;
                alert("粘贴成功!");
            }
        </script>
     <input id="Text1" type="text" /><input id="Button1" type="button" value="复制" onclick="CopyText()" />
            <br /><br />
            
             <input id="Text2" type="text" /><input id="Button2" type="button" value="粘贴" onclick="PasteText()" />