<!DOCTYPE html>
<html>
<head>
<body style="white-space:pre">0123456789
<script>
var t = document.body.firstChild;
var sel = window.getSelection();
sel.collapse(t, 2);
sel.extend(t, 8);
</script>
</body>
</html>