node-webodf
Version:
WebODF - JavaScript Document Engine http://webodf.org/
28 lines (23 loc) • 1.01 kB
HTML
<html>
<head><title></title>
<script>
window.onload = function () {
var selection = window.getSelection(),
p = document.createElement("p"),
textnode = document.createTextNode("hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello "),
range;
document.body.appendChild(p);
p.appendChild(textnode);
selection.removeAllRanges();
range = document.createRange();
range.setStart(textnode, 1);
selection.removeAllRanges();
selection.addRange(range);
selection.modify("move", "forward", "line");
alert(selection.rangeCount + " " + selection.getRangeAt(0).startOffset);
}
</script>
</head>
<body>
</body>
</html>