如何从 iframe 中调用主文档中的 javascript 函数(ckeditor 插件)
我构建了一个简单的 CKeditor 3 插件,其中只有一个按钮,当有人单击它时,该按钮应该调用 JS 函数。
插件(有人点击时的代码)看起来像这样并且正在工作:
var openAssetsBrowser = {
exec:function(editor){
openAssetsBrowser();
}
};
我总是收到错误“openAssetsBrowser不是一个函数”
该函数本身位于页面中的某个位置,我认为顺序不重要,因为整个页面都被读取了首先,在任何人点击触发该函数的ckeditor按钮之前,
在页面中某处的链接上调用它(例如使用jquery)就可以了:
$("a#linkOpenFileManager").click(function(){
openAssetsBrowser();
return(false);
});
有谁知道为什么不能从CKeditor插件中调用该函数?
更新:粘贴完整的功能代码而不是“openAssetsBrowser();”时在插件中,一切正常,但这并不是真正可重用的代码......
I've built a simple CKeditor 3 plugin with one button that should just call a JS-function when somebody clicks it.
The plugin (code when somebody clicks) looks like this and is working:
var openAssetsBrowser = {
exec:function(editor){
openAssetsBrowser();
}
};
I always get the error "openAssetsBrowser is not a function"
The function itself is somewhere in the page, I thought the order shouldn't matter since the whole page is read first, before anyone would lclick the ckeditor button that triggers the function
Calling it on a link somewhere (e.g. with jquery) in the page just works:
$("a#linkOpenFileManager").click(function(){
openAssetsBrowser();
return(false);
});
Does anyone know why the function cannot be called from within the CKeditor plugin?
update: when pasting the complete function code instead of "openAssetsBrowser();" in the plugin, all works, but that's not really re-usable code...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
现在这很容易了。
parent.openAssetsBrowser() 成功了!
now that was easy.
parent.openAssetsBrowser() did the trick!