2017-04-03 50 views
0

我在父模板上有一个CKEditor实例,我想在onc​​lick之后将数据从iframe插入文本区域。我该怎么去做呢?这是我的代码到目前为止,我做错了什么?如何从iframe访问父窗口中的CKEditor实例?

<br><input type="button" id="change_text" value="Change Text"` onclick="myFunction()"> 

    <script> 
     function myFunction() { 
     parent.document.body.style.backgroundColor = "red"; //This line works, setting parent page background to red 
     parent.document.CKEDITOR.instances['id_body'].setData($('input:radio[name=temp_name]:checked').val()); //Radio button value from iframe page. This line does not work 
    } 

    </script> 

回答

0

我明白了。刚刚必须使用
parent.CKEDITOR.instances 而不是parent.document.CKEDITOR.instances