感觉实现起来应该不难,但是没有编程基础试了好几个小时都没成功,我想实现下面的功能:textbox1, textbox2 ,一个button按下button后, 把“小学班主任"textbox1的值",初中班主任"textbox2的值",都很好”这句话复制到粘贴板上。
希望能得到您的指点,谢谢

解决方案 »

  1.   

    <script type="text/javascript">
    function copyData(str) {
    window.clipboardData.setData("Text",str);
    }
    var stu = textbox1的值;
    var th = 初中班主任的值;
    copyData(stu+th+"都很好");
    </script> 
      

  2.   

    <html>
        <head>
           <script>
            function A()
            {
            var text="小学班主任"+document.getElementById('txt1').value+",初中班主任"+document.getElementById('txt2').value+",都很好";
            window.clipboardData.setData("aaa",text);
            }
           </script>
        </head>    <body>
         <input type="text" id="txt1"/>
         <input type="text" id="txt2"/>
            <input type="button" onclick="A();" value="拷贝到剪切板"/>
        </body>
    </html>
      

  3.   

    window.clipboardData.setData(键,值);
      

  4.   

    <html>
        <head>
           <script>
               function A()
               {
                   var text=document.getElementById('txt1').value+document.getElementById('txt2').value+",都很好";
                   window.clipboardData.setData("Text",text);
               }
           </script>
        </head>    <body>
            <input type="text" id="txt1" value="小学班主任"/>
            <input type="text" id="txt2" value="初中班主任"/>
            <input type="button" onclick="A();" value="拷贝到剪切板"/>
        </body>
    </html>
      

  5.   


    internet选项-安全-自定义级别-其他
    这里面有浏览器的各个安全设置,比如框架,跨域...,其中的
    "允许用户通过脚本进行粘贴",这个选项必须为启用,setData才可以使用
      

  6.   

    不好意思,window.clipboardData.setData("text",text);
    这里不能用"aaa",只能用"text"
    <html>
        <head>
           <script>
               function A()
               {
                   var text="小学班主任"+document.getElementById('txt1').value+",初中班主任"+document.getElementById('txt2').value+",都很好";
                   window.clipboardData.setData("text",text);
               }
           </script>
        </head>    <body>
            <input type="text" id="txt1"/>
            <input type="text" id="txt2"/>
            <input type="button" onclick="A();" value="拷贝到剪切板"/>
        </body>
    </html>
      

  7.   

    确实把“aaa”改为"text"就可以了。
      

  8.   

    http://www.cnblogs.com/sweting/archive/2009/12/21/1628929.html