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

Get Text from iFrame.

2 Answers 108 Views
Editor
This is a migrated thread and some comments may be shown as answers.
izverg
Top achievements
Rank 1
izverg asked on 06 Mar 2009, 08:29 PM
Hi

I have an iFrame with RAD Editor in it.

I have a button outside the ifame.

How do i get text/html of the Editor while pressing the button?

I use alert(window.frames["iFramID"].getText()); but it doesn't seem to work.

What am i doing wrong?



2 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 09 Mar 2009, 08:59 AM
Hi Yuri,

Here is an example how to call a function located in the iframe from the parent page:

Parent.aspx

        <input type="button" value="Get Editor Content" onclick="CallInlineFunction();return false;" />
        <script type="text/javascript">
        function CallInlineFunction()
        {
           //execute the GetRadEditorContent function placed in the page loaded in the IFRAME
           document.getElementById('iFramID').contentWindow.GetRadEditorContent();
        }
        </script>
        <iframe src="Default.aspx" id="iFramID" style="width: 779px; height: 535px"></iframe>


Child.aspx

<script type="text/javascript">
function GetRadEditorContent()
{
    var editor = $find("<%= RadEditor1.ClientID %>"); //get a reference to RadEditor
    alert(editor.get_html(true)); //get the editor's content
}
</script>
<telerik:RadEditor id="RadEditor1"
    Runat="server">
    <Content>
</Content>
</telerik:RadEditor> 



All the best,
Rumen
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
izverg
Top achievements
Rank 1
answered on 09 Mar 2009, 04:05 PM
thanks for this.


The reason why it wasn't working for me because my iframe parents and child were in different domains. If i had my script debug on i would have known this earlier.

Thanks,

Yury
Tags
Editor
Asked by
izverg
Top achievements
Rank 1
Answers by
Rumen
Telerik team
izverg
Top achievements
Rank 1
Share this question
or