managing html rich text selections

Posted by swami on Stack Overflow See other posts from Stack Overflow or by swami
Published on 2010-05-21T08:54:10Z Indexed on 2010/05/21 9:00 UTC
Read the original article Hit count: 256

Filed under:
|
|
|
|

Hi,

I am writing a component for a web app which will display some html, and let me capture and manipulate the selection boundaries (of the text selected by the user). I have done this successfully (for Mozilla) with a simple div element using window.getSelection(). However, the browser selection API is different for IE.

If I were to use a textarea instead (for interacting with the selection api), is there a uniform API across the browsers? Then I would need to overlay a DIV on top of this to display the styled text, and presumably I'd need to manage the cursor etc...

Basically I want a rich text editor - but without editing. Does anyone have any advice on the best way to go about this, which is quick, simple and cross browser compatible. I don't want to spend ages reinventing the wheel...

(If anyone's interested - this is for an online xml editor. I capture the users selection on a html version of the xml doc and then send the selection offsets info to the server, where the real xml doc gets marked up).

Kind Regards

Swami

© Stack Overflow or respective owner

Related posts about Xml

Related posts about html