View Full Version : Finding caret position in mozilla

10-14-2003, 06:46 PM

I'm doing a little script which adds some tags into a text in a textarea, and I can't get it to work fine on NS4 & mozilla. See for yourself: (click on "URL")

In fact it seems to work, exept that it always adds the tags at the end of the text, instead of where the caret is. Any idea how it would be possible to get it working on those browsers?


10-14-2003, 06:51 PM
Try using the search feature. I've seen this topic come up quite a few times. :thumbsup:

10-14-2003, 07:11 PM
Have a look at <http://www.mozilla.org/docs/dom/domref/dom_range_ref.html#998954>, <http://www.pbwizard.com/Articles/Moz_Range_Object_Article.htm>,

10-14-2003, 08:31 PM
what you are looking for is(Moz version only) :
var oldStart=field.selectionStart;// gives the index of the cursor in the field if it's an insertion point
var oldEnd=field.selectionEnd;// gives the end of selection range if it's a selected text
NS4 - forget about it.