0

I want to keep the text selection when the textarea loses the focus.

For Internet Explorer and without any jQuery.

5
  • 4
    Why would you want to do this? This isn't what the user expects to happen. Commented Nov 14, 2010 at 17:19
  • well, if i asked that probably I need it right? :) Commented Nov 14, 2010 at 17:24
  • It's a lot of code, so I don't have the time to write up an answer here right now, but see stackoverflow.com/questions/1592637/… for an idea of how to do it (that example uses jQuery, but only for the event handling -- the text selection stuff is all plain javascript). Commented Nov 14, 2010 at 17:30
  • You mean keep it visually, or just have CTRL+C copy into the clipboard the last selected text from the textarea? Commented Nov 15, 2010 at 12:24
  • I mean when i return to text box, the selection of text should be as it was before. Commented Nov 17, 2010 at 17:08

1 Answer 1

0

If the selection needs to be visible only when the textarea has the focus, you could store the selected start and end, at onblur and at the next onfocus set it again.

Sign up to request clarification or add additional context in comments.

1 Comment

the selection.createRange(); is empty after onblur event (Internet Explorer)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.