网络编程
位置:首页>> 网络编程>> Asp编程>> FCKeditor编辑器实战技巧(2)

FCKeditor编辑器实战技巧(2)

作者:柠檬园主 来源:3rgb.com 发布时间:2007-10-08 21:13:00 

标签:编辑器,fckeditor,技巧

3、外联编辑条(多个编辑域共用一个编辑条)

这个功能是2.3版本才开始提供的,以前版本的FCKeditor要在同一个页面里用多个编辑器的话,得一个个创建,现在有了这个外联功能,就不用那么麻烦了,只需要把工具条放在一个适当的位置,后面就可以无限制的创建编辑域了,如图

要实现这种功能呢,需要先在页面中定义一个工具条的容器:<div id="xToolbar"></div>,然后再根据这个容器的id属性进行设置。

ASP实现代码:


<div id="fckToolBar"></div>
<%
Dim oFCKeditor 
Set oFCKeditor = New FCKeditor 
with oFCKeditor 
.BasePath = fckPath
.Config("ToolbarLocation") = "Out:fckToolBar"
.ToolbarSet = "Basic"
.Width = "100%"
.Height = "200"
.Value = ""
.Create "jcontent"
.Height = "150"
.Value = ""
.Create "jreach"
end with
%>


JAVASCRIPT实现代码:

<div id="xToolbar"></div>
FCKeditor 1:
<script type="text/javascript">
<!--
// Automatically calculates the editor base path based on the _samples directory.
// This is usefull only for these samples. A real application should use something like this:
// oFCKeditor.BasePath = '/fckeditor/' ; // '/fckeditor/' is the default value.
var sBasePath = document.location.pathname.substring(0,document.location.pathname.lastIndexOf('_samples')) ;
var oFCKeditor = new FCKeditor( 'FCKeditor_1' ) ;
oFCKeditor.BasePath = sBasePath ;
oFCKeditor.Height = 100 ;
oFCKeditor.Config[ 'ToolbarLocation' ] = 'Out:parent(xToolbar)' ;
oFCKeditor.Value = 'This is some <strong>sample text</strong>. You are using FCKeditor.' ;
oFCKeditor.Create() ;
//-->
</script>
<br />
FCKeditor 2:
<script type="text/javascript">
<!--
oFCKeditor = new FCKeditor( 'FCKeditor_2' ) ;
oFCKeditor.BasePath = sBasePath ;
oFCKeditor.Height = 100 ;
oFCKeditor.Config[ 'ToolbarLocation' ] = 'Out:parent(xToolbar)' ;
oFCKeditor.Value = 'This is some <strong>sample text</strong>. You are using FCKeditor.' ;
oFCKeditor.Create() ;
//-->
</script>


此部分的详细DEMO请参照_samples/html/sample11.html,_samples/html/sample11_frame.html

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com