Source:
http://stackoverflow.com/questions/1891444/how-can-i-get-cursor-position-in-a-textarea[
^]
for cross-browser compatibility you will need to test for a few capabilities:
1. selectionStart (which you have already found out)
2. selection (which is shown in the link above)
essential code:
var pos = 0;
if("selectionStart" in el) {
pos = el.selectionStart;
} else if("selection" in document) {
el.focus();
var Sel = document.selection.createRange();
var SelLength = document.selection.createRange().text.length;
Sel.moveStart("character", -el.value.length);
pos = Sel.text.length - SelLength;
}
return pos;