Javascript 从弹出窗口将HTML插入CKeditor

Javascript 从弹出窗口将HTML插入CKeditor,javascript,jquery,ckeditor,Javascript,Jquery,Ckeditor,我创建了调用外部弹出窗口的插件: exec : function( editor ) { window.open('index.php?mod=xxxx','Name popup','width=900,height=600'); } 那部分很好用。如何将数据发送回CKeditor?我想在带有jquery的CKeditor的opener实例的当前位置上附加一些HTML 我试过这个,但不起作用: $('a#clickMe').click(function() { window

我创建了调用外部弹出窗口的插件:

exec : function( editor )
{
    window.open('index.php?mod=xxxx','Name popup','width=900,height=600');
}
那部分很好用。如何将数据发送回CKeditor?我想在带有jquery的CKeditor的opener实例的当前位置上附加一些HTML

我试过这个,但不起作用:

$('a#clickMe').click(function()
{ 
     window.opener.CKeditor.insertHtml('Bla bla bla');
});
尝试:

然而,我不知道如果不先聚焦编辑器,它是否会一直工作。您更应该使用CKEditor的对话API。

找到了一种方法:

exec : function( editor )
{
    window.open('index.php?mod=xxxx&CKEditor='+CKEDITOR.currentInstance.name,'Name popup','width=900,height=600');
}
然后将传递的$\u GET['CKEditor']插入元素'rel'属性

Html:

<a id="clickMe" rel="<?=$_GET['CKEditor']?>">click me</a>

一种不使用GET变量的方法-在javascript中添加一个全局变量(例如在config.js文件中)

然后在插件中

exec : function( editor )
{
    myEditorInstance=editor;
    window.open('index.php?mod=xxxx','Name popup','width=900,height=600');
}
然后,您可以从弹出窗口使用

window.opener.myEditorInstance.insertHtml('Bla bla bla');
这还意味着,如果页面上有多个编辑器,则弹出窗口与打开窗口的实例相关

var myEditorInstance;
exec : function( editor )
{
    myEditorInstance=editor;
    window.open('index.php?mod=xxxx','Name popup','width=900,height=600');
}
window.opener.myEditorInstance.insertHtml('Bla bla bla');