javascriptdomteleriktelerik-editor

DOM Manipulation of Telerik Text Editor


I am trying to manipulate a Telerik Text Editor element with JavaScript. I am using the following code:

document.getElementById("ctl00_ContentPlaceHolder1_RadEditor1_contentIframe").childNodes

Example of Telerik Text Editor @ http://demos.telerik.com/aspnet-ajax/editor/examples/overview/defaultcs.aspx

However, I get the following error: "Your browser does not support inline frames or is currently configured not to display them" with all major browsers.

Does any DOM ninja out there know how to solve this? I want to set the text value to a string.

Thanks


Solution

  • Try the following code:

    var newContent = "New content here...",
    iframe = document.getElementById("ctl00_ContentPlaceHolder1_RadEditor1_contentIframe");
    

    The following line changes the whole thing:

    iframe.src = "data:text/html;charset=utf-8," + newContent; //to change the whole iframe
    

    Or, you can change the iframe body only:

    iframe.contentWindow.document.getElementsByTagName("BODY")[0].innerHTML = newContent; //to change body only