This is a migrated thread and some comments may be shown as answers.

HTML Cleanup

1 Answer 87 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Stephen
Top achievements
Rank 2
Stephen asked on 10 Jan 2009, 02:53 AM
Does anyone know if I can get direct access to the HTML cleanup code that is used in the editor. I need to take a small portion of text blocks for a preview mode; but those blocks sometime have HTML in them and I don't have time to parse the HTML to find a safe spot to chop it. I've noticed that the editor always cleans up open or partial tags but I'm much rather do this server side or worse case do it directly in javascript instead of needed to create an editor just for this purpose.

Thanks,
Stephen

1 Answer, 1 is accepted

Sort by
0
Accepted
Rumen
Telerik team
answered on 13 Jan 2009, 03:41 PM
Hello Stephen,

RadEditor uses the browser's rich-text editing (RTE) engine, which works with HTML objects and when some tag is not well formed, i.e. the tag is not properly closed (there is only opening tag for example <DIV>) or the opening tag is missing (there is only a closing tag </DIV>), then the browser automatically correct this by closing the tag or adding the opener tag (<DIV></DIV>).

The RTE engine is used by the editable DIV and IFRAME elements and you can achieve your scenario by pasting the content directly in an editable IFRAME or DIV elements, the browser will correct the non well formed content and you will be able to obtain it cleaned from the IFRAME and set it to your Preview mode.

You can obtain the content of the editable iframe with the following code:

iframe.contentWindow.document.body.innerHTML

Best regards,
Rumen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Editor
Asked by
Stephen
Top achievements
Rank 2
Answers by
Rumen
Telerik team
Share this question
or