Roll src/third_party/WebKit e0eac24:489c548 (svn 193311:193320)
[chromium-blink-merge.git] / content / test / data / touch_selection.html
blob89d768316132ec07618d91eb3c6cb913d1d1c61e
1 <html>
2 <div id='textDiv'>Some text we can select</div>
3 <input id='textfield' type="text" value="Text in a textfield">
4 <script>
6 function select_all_text() {
7 var div = document.getElementById("textDiv");
8 var range = document.createRange();
9 range.selectNodeContents(div);
10 var sel = window.getSelection();
11 sel.removeAllRanges();
12 sel.addRange(range);
15 function get_selection() {
16 return (window.getSelection() + "");
19 function focus_textfield() {
20 document.getElementById("textfield").focus();
21 // Focusing the textfiled selects its text. Collapse selection to a cursor.
22 window.getSelection().collapseToStart();
25 function get_cursor_position() {
26 var div = document.getElementById("textfield");
27 var start = div.selectionStart;
28 var end = div.selectionEnd;
29 if (start == end)
30 return start;
31 else
32 return -1;
35 </script>
37 </html>