views:

14

answers:

0

Hi all,

I have a problem with a little function which should give me the Cursor position :

   function getCursorPos() {   
        var selObj = window.getSelection();                       
        alert (selObj.anchorOffset);      
}

It works only when I use it on a text whitout HTML tags.

For example : "The cat is black"

If I use it on a text with HTML tags, the function doesn't give me the good cursor position.

For example : "The <strong>cat</strong> is black"

Do you know why and how I can do to solve this ?

Thanks.