Set textarea selection in Internet Explorer

Posted by Tatu Ulmanen on Stack Overflow See other posts from Stack Overflow or by Tatu Ulmanen
Published on 2009-12-30T16:33:59Z Indexed on 2010/06/02 5:43 UTC
Read the original article Hit count: 301

I'm looking for a way to set a selection in a textarea in Internet Explorer. In other browsers, this works just fine:

textarea.selectionStart = start;
textarea.selectionEnd = end;

In IE, I assume I have to use createRange and adjust the selection somehow, but I cannot figure out how.

Extra bonus points for a link to a proper documentation about createRange and associated methods, MSDN isn't helping out much.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about internet-explorer