OLD | NEW |
1 <html> | 1 <html> |
| 2 <style> |
| 3 /* Add space between div and textfield so that touch selects the text in div. */ |
| 4 #textDiv { |
| 5 margin-bottom: 30px; |
| 6 } |
| 7 </style> |
| 8 <body> |
| 9 <div id='dummy'>Dummy Padding Text</div> |
2 <div id='textDiv'>Some text we can select</div> | 10 <div id='textDiv'>Some text we can select</div> |
| 11 <div id='dummy'>Dummy Padding Text</div> |
| 12 |
3 <input id='textfield' type="text" value="Text in a textfield"> | 13 <input id='textfield' type="text" value="Text in a textfield"> |
| 14 </body> |
4 <script> | 15 <script> |
5 | 16 |
6 function focus_textfield() { | 17 function focus_textfield() { |
7 document.getElementById('textfield').focus(); | 18 document.getElementById('textfield').focus(); |
8 // Focusing the textfiled selects its text. Collapse selection to a cursor. | 19 // Focusing the textfiled selects its text. Collapse selection to a cursor. |
9 window.getSelection().collapseToStart(); | 20 window.getSelection().collapseToStart(); |
10 } | 21 } |
11 | 22 |
12 function get_point_inside(element) { | 23 function get_point_inside(element) { |
13 var rect = element.getBoundingClientRect(); | 24 var rect = element.getBoundingClientRect(); |
(...skipping 12 matching lines...) Expand all Loading... |
26 get_point_inside(document.getElementById('textfield')); | 37 get_point_inside(document.getElementById('textfield')); |
27 } | 38 } |
28 | 39 |
29 function empty_textfield() { | 40 function empty_textfield() { |
30 document.getElementById('textfield').value = ""; | 41 document.getElementById('textfield').value = ""; |
31 } | 42 } |
32 | 43 |
33 </script> | 44 </script> |
34 | 45 |
35 </html> | 46 </html> |
OLD | NEW |