如何从iframe访问父窗口中的CKEditor实例?

时间:2017-04-03 14:09:45

标签: javascript jquery html iframe ckeditor

我在父模板上有一个CKEditor实例,我希望在onclick之后将数据插入iframe的文本区域。我该怎么做呢?到目前为止,这是我的代码,我做错了什么?

<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>

1 个答案:

答案 0 :(得分:1)

我明白了。只是不得不使用
parent.CKEDITOR.instances 而不是parent.document.CKEDITOR.instances

相关问题