js代码复制文本框中内容:
1 2 3 4 5 6 7 8 9 10 11 | <script language= "<a href=" http: //www.jb200.com/js/" target="_blank" class="infotextkey">javascript</a>"> /** * 复制文本框 */ function copyinput() { var input=document.getElementById( "inputid" ); //input的ID值 input.select(); //选择对象 document.execCommand( "Copy" ); //执行浏览器复制命令 } </script> |
JS代码复制TABLE表格的内容:
1 2 3 4 5 6 7 8 9 10 11 12 13 | <script language= "Javascript" > /** * 复制表格 * site www.jb200.com */ function CopyTable() { var txt = document.body.createTextRange(); txt.moveToElementText(“tableid”); //表格的ID值 txt.select(); //选择对象 document.execCommand( "Copy" ); //执行浏览器复制命令 } </script> |
有了以上的二种方法,复制文本框或表格内容,即可轻松实现了。