开发者

managing html rich text selections

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 - th开发者_开发百科is 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


Using a textarea won't help: the API is not consistent there either. I'd suggest using IERange to get a consistent API for selections.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜