Home: htmlArea 2: htmlArea 2 & 3 archive (read only): htmlArea v2.0:
How to: Get HTML to the left and right of cursor (separately)



coling
Novice

Mar 11, 2003, 4:08 PM


Views: 7651
How to: Get HTML to the left and right of cursor (separately)

Please excuse me (new here) if this has already been asked:

Is there a way to "get" the HTML to the left, and (separately) to the right of the cursor. ie. with the objective not to edit the contents, but to retrieve the two parts after the user has left-clicked somewhere in the "textarea"?

Looking at editor.js, I would think of creating function(s) similar to editor_getHTML, eg. editor_getLeftHTML and editor_getRightHTML, both of which determine where the cursor is, and return their respective portions.


Benjamin
Staff


Mar 16, 2003, 6:21 PM


Views: 7617
Re: [coling] How to: Get HTML to the left and right of cursor (separately)

Hi Coling,

Yes, you can do this by creating a 'range'. Take a look at my code for the link with target popup. In it, I use some code that does almost precisely this.

Hopefully that should point you in the right direction. :-)
Ben
interactivetools.com