Tuesday 22 November 2011

Asp.Net: Get Text in RadEditor from Telerik

Question:
How do I get the html text of the Telerik RadEditor with JavaScript, jQuery?


Answer:
You must know that the RadEditor keeps its html in an IFrame.
Once you know this, you can (for example) use jQuery to get the IFrames in a given div, then get the IFrames contents, find its Body and then get its text or innerHTML.

Here is an example
// editPnlId is the id of a div around the editor.
// get text without html
var editorText = jQuery("#" + editPnlId + " iframe").contents().find("body").text();
// get text without html
var editorHtml = jQuery("#" + editPnlId + " iframe").contents().find("body").html();




No comments: