2

With this code I can check the caret position in a textarea in firefox:

document.getElementById("myTextArea").selectionStart

This doesn't work in IE 8. How can I get the caret position in IE 8?

kayahr
  • 20,913
  • 29
  • 99
  • 147
  • 1
    Possible duplicate: http://stackoverflow.com/questions/263743/how-to-get-cursor-position-in-textarea – Tim Down Apr 13 '10 at 09:37

1 Answers1

2

See the answers here: Caret position in textarea, in characters from the start

Edit

I sorted out the line breaks issue in IE and posted an answer here: Caret position in textarea, in characters from the start

Community
  • 1
  • 1
Tim Down
  • 318,141
  • 75
  • 454
  • 536
  • Hm, still not perfect because empty lines in the textarea produces problems (Which is also mentioned in a comment of the linked question), but I think this is the closest I can get. Thanks. – kayahr Apr 13 '10 at 10:45