views:

407

answers:

1

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?

+1  A: 

See the answers here: http://stackoverflow.com/questions/263743/how-to-get-cursor-position-in-textarea

Edit

I sorted out the line breaks issue in IE and posted an answer here: http://stackoverflow.com/questions/263743/how-to-get-cursor-position-in-textarea/3373056#3373056

Tim Down
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
Edited my answer.
Tim Down