I’m trying to use the document.getSelection to select text I have entered in an text area for a WYSIWYG editor. It only works if you select text outside the text area though. I don’t know if there is a way you can make it select text inside the text area?
Below is the text area for a WYSIWYG text editor:
<iframe id="editor" width="100%" height="400px" contentEditable="true"></iframe>
You need to get the iframe document’s selection:
Note that for Internet Explorer you need document.selection.createRange() instead of document.getSelection().