Getting text on caret position
<p>Am using Rad Editor control.I need to develop an auto-complete like MS Word.Means if i type some keyword and press a key an auto-complete with list items is shown.50% i have done my job using range object.My coding will work for plain text.But its completely going wrong when html tags are there in editor.The caret position obtained is wrong. so that i can't trace the word near to cursor position.I googled and found some solutions.But no use for above scenario.
Here is my code to get caret position</p>

<pre><code>function getCaret(el) {
if (el.selectionStart) {
    return el.selectionStart;
} else if (document.selection) {
    el.focus();
    var r = document.selection.createRange();
    savedRange = r;
    if (r == null) {
        return 0;
    }
    var re = el.createTextRange(),
    rc = re.duplicate();
    re.moveToBookmark(r.getBookmark());
    rc.setEndPoint('EndToStart', re);
    return rc.text.length;
}
return 0;
</code></pre>

<p>}</p>

<blockquote>
  <p>This link shows my problem <a href="http://jsfiddle.net/2YcaX/1/" rel="nofollow">http://jsfiddle.net/2YcaX/1/</a>
  Move arrow key and see the position obtained</p>
</blockquote>

<p>In Fact my code is different from the one used in demo.But output obtained is same.But am in need of that urgently.Please help me.</p>
