[thelist] request for XB caretPOS code...

jsWalter jsWalter at torres.ws
Tue Nov 11 15:46:16 CST 2003


I have a piece of code that will retrieve the current position of a the
insertion bar within a TEXT element at that given moment...

   /* Copyright (C) George Zabanah April 8, 2003 */
   /* Please feel free to use this ... but leave this header on top */
   // 'bolStart' = true  - return beginning point of selection
   // 'bolStart' = false - return ending point of selection
   // If no select is made, then either will return current caret location
   function ReturnCaretPOS ( bolStart )
   {
      var caretPos = window.document.selection.createRange().duplicate();
          caretPos.collapse(bolStart);
          caretPos.moveStart("textedit",-1);
      return caretPos.text.length;
   }

This works great in IE 4/5/6.

Does anyone have any ides on how to accomplish this in NN, Mozilla, Firebird
and Opera?

Yes, I'm working on another X-Browser project.

Thanks for your help.

Walter




More information about the thelist mailing list