createTextRange选中测试表格

<INPUT TYPE="button" value="选中测试表格" onclick="CopyTable()">
测试
<TABLE border="1" id="oTable">
<TR>
 <TD>测试表格</TD>
 <TD>测试表格</TD>
</TR>
<TR>
 <TD>测试表格</TD>
 <TD>测试表格</TD>
</TR>
</TABLE>文字
<SCRIPT LANGUAGE="JavaScript">
<!--
function CopyTable()
{
 var txt = document.body.createTextRange();
 txt.moveToElementText(oTable);
 txt.select();
}
//-->
</SCRIPT>
原文地址:https://www.cnblogs.com/zhangpengshou/p/861554.html