function caretPos(el)
{
var pos = 0;
// IE Support
if (document.selection)
{
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;
}
// Firefox support
else if (el.selectionStart || el.selectionStart == '0')
pos = el.selectionStart; //нашли индекс кликнутого символа
var str = el.value;
var re = /(?!\d+)[\u00C0-\u1FFF\u2C00-\uD7FF\w]+/gi; //Это всего лишь аналог "\w+"
while ((match = re.exec(str)) != null) {
if (pos >= match.index && (pos <= match.index + match[0].length)) //если индекс в пределах слова
alert(match);
}
}
Вопрос на Google Answers
Поиск позиции в textarea