简体   繁体   English

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

[英]How can I access CKEditor instance in parent window from iframe?

I have a CKEditor instance on a parent template and I'd like to insert data into its text area from the iframe after an onclick. 我在父模板上有一个CKEditor实例,我想在单击后将数据从iframe插入其文本区域。 How would I go about doing it? 我将如何去做? This is my code so far, what am I doing wrong? 到目前为止,这是我的代码,我在做什么错?

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

I got it. 我知道了。 Just had to use 只是不得不使用
parent.CKEDITOR.instances instead of parent.document.CKEDITOR.instances parent.CKEDITOR.instances而不是parent.document.CKEDITOR.instances

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM