HtmlEditor :  Phorum 5 The fastest message board... ever.

This is the discussion forum for the HtmlEditor. See also the HtmlEditor home page, where you can download the control, and the Documentation Wiki, a collaborative project for documenting the control.

Goto Thread: PreviousNext
Goto: Forum ListMessage ListNew TopicSearchLog In
Get selection bounds in source code
Posted by: Adrian (---.rdsnet.ro)
Date: Wednesday, 24-Dec-2008, 22:06:46

Hi,

I'm building an app which, at a certain point, needs to split a HTML page in three parts - a header, a footer and a body. To do this, I want to allow the user to highlight the body part. I can't seem to manage that.

Here's something I've tried:

IHTMLTxtRange tr = (IHTMLTxtRange)sel.createRange();
String content = tr.htmlText;
IHTMLTxtRange beg = tr.duplicate();
beg.collapse(true);
beg.moveStart("character", -int.MaxValue);
String header = beg.htmlText;
IHTMLTxtRange ndg = tr.duplicate();
ndg.collapse(false);
ndg.moveEnd("character", int.MaxValue);
String footer = ndg.htmlText;

Hacky, indeed - inspired from a solution posted in this forum.
This works somewhat, but seems to add additional markup (meaning header+content+body is not a valid HTML page).
Is there any way to get the exact location in the original source (not the one returned from an IHTMLTxtRange's htmlText) that the caret is positioned at?
If not, can you suggest a workaround? (I don't care about header+body+footer being identical as source to the original, but it should be equivalent).

Thanks a lot!



Your Name: 
Your Email: 
Subject: 
Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically.
uD9UY
This forum powered by Phorum.