![]() ![]() A user may make a selection from left to right (in document order) or right to left (reverse of document order). To obtain a Selection object for examination or manipulation, call window.getSelection (). To print the document, use the print method from Document Editor instance. The typical wayĮvery textarea and text input, should have available the selectionStart and selectionEnd properties which contains the character index of the start position of the selection and the character index of the end position of the selection respectively. A Selection object represents the range of text selected by the user or the current position of the caret. Print in JavaScript DocumentEditor control. In case that not any text is selected, those values (start and end) will be the same, which means that they're equivalent to the position of the cursor in the element. These values (start and end) provide always an integer value with the index of the selected text within a textarea or text input. Although you won't get a property named " cursorPosition" or " caretPosition", you can deduct this value from the selectionStart property from the element which is basically the same. This method will block while the print dialog is open. If the document is still loading when this function is called, then the document will finish loading before opening the print dialog. Inside the function, we get the selection and the selected string using document.getSelection (). In this article Window: print () method Opens the print dialog to print the current document. Next, we write the handler function for the onpointerup event of the element carrying the sample text. A Selection object represents the range of text selected by the user or the current position of the caret. Retrieve the position of the cursor (caret) within a textarea is easier than you think. In this code, we first get a copy of the selection menu control inside , then assign it to the control variable.![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |