jQuery:设置ckeditor baseurl

时间:2011-08-25 13:33:32

标签: jquery ckeditor

我正在使用ckEditor和它自己的jQuery适配器,我想定义编辑器的baseUrl,以便在html中显示图像。

这是我的代码 - 遗憾的是不起作用:

    var txt = $("textarea");
    txt.ckeditor();
    var editor = txt.ckeditorGet();
    editor.baseurl = "/myweb1/test/";

任何想法有什么不对?

感谢

1 个答案:

答案 0 :(得分:4)

您要查找的配置属性实际上是ckeditor.config.baseHref

您可以通过ckeditor()初始化程序传递配置选项,如下所示:

<html>
<head>
<script type="text/javascript" src="jquery.js"></script>  
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="ckeditor/adapters/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function() {
    $( 'textarea' ).ckeditor({baseHref : "http://www.google.com/"});
});
</script>
</head>
<body>

<textarea cols="80" id="editor1" name="editor1" rows="10">
&lt;img src="intl/en_ALL/images/logo.gif" /&gt;
</textarea>

</body>
</html>

您也可以这样动态地执行此操作:

txt = $( 'textarea' ).ckeditor();
txt.ckeditorGet().config.baseHref="http://www.google.com/"

可以在此处找到更多信息 - http://ckeditor.com/blog/CKEditor_for_jQuery

相关问题