<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript">
window.onload = function() {
var table = document.getElementById("table");
var selStart = table.tBodies[0].rows[0].cells[4];
var selEnd = table.tBodies[0].rows[3].cells[0];
var range;
var ie /*@cc_on = true @*/;
if(ie) {
range = document.selection.createRange();
var range2 = range.duplicate();
range.moveToElementText(selStart);
range2.moveToElementText(selEnd);
range.setEndPoint("EndToEnd", range2);
range.select();
} else {
range = document.createRange();
range.selectNodeContents(selEnd);
range.setStart(selStart, 0);
var selection = window.getSelection();
selection.removeAllRanges();
selection.addRange(range);
}
};
</script>
</head>
<body>
<table id="table" summary="">
<tbody>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<td>6</td>
<td>7</td>
<td>8</td>
<td>9</td>
<td>10</td>
</tr>
<tr>
<td>11</td>
<td>12</td>
<td>13</td>
<td>14</td>
<td>15</td>
</tr>
<tr>
<td>16</td>
<td>17</td>
<td>18</td>
<td>19</td>
<td>20</td>
</tr>
</tbody>
</table>
</body>
</html>
Range, TextRange и Selection