灯箱:无法从 iframe 访问父 javascript obj

Lightbox: can't access parent javascript obj from iframe

我正在使用灯箱 (highslide JS / highslide.com),打开时会显示所见即所得 Javascript 编辑器 (CKEditor / ckeditor.com)。我这样称呼灯箱(或扩展器):

<a href="script.php" onclick="return hs.htmlExpand(this,{objectType:'iframe'})">click here</a>

在父页面中,我为编辑器添加了 javascript:

<script type="text/javascript" src="ckeditor/ckeditor.js"></script>

ckeditor.js 的第一行(截断)是:

(function(){if(window.CKEDITOR&&window.CKEDITOR.dom)return;if(!window.CKEDITOR)window.CKEDITOR=(function()

我的问题是编辑器在扩展器中不起作用 - 类型错误:parent.window.hs.CKEDITOR 未定义

为了解决这个问题,我需要在 script.php 中调用 ckeditor.js 这使得扩展器打开速度变慢,因为它必须再次拉取 JS 文件,即使父 window已经这样做了。

在 iframe 中这样调用 CK 编辑器:

<script type="text/javascript">
CKEDITOR.replace( 'bodytext' ,
{
basePath : '/admin/ckeditor/'
});
</script>

我试过给 CKEDITOR 添加前缀 'parent' , 'parent.window', 'window' 都没有成功

是否有解决办法?

谢谢!

我不确定我是否正确理解了你的问题,但基于:

In the parent page I include the javascript for the editor:

我的答案是 - 您必须在使用它的同一文档中包含 ckeditor.js