首页 > 课堂 > 基础知识 > 正文

FCKeditor 技巧

2020-10-28 20:24:44
字体:
来源:转载
供稿:网友
FCKeditor至今已到了2.3.1版本了,於的WEB者,也基本上都已「知多少」了,很多人其融放到自己的目中,更有很多大型的站中吃到了甜。今天始,我一的介自己在使用FCKeditor程中的一些技巧,然些其是FCK本就有的,只是很多人用FCK的候而已 :P

1、打器
很多候,我在打面的候不需要直接打器,而在用到的候才打,一有很好的用,另一方面可以消除FCK在加面打速度的影,如所示
uploads/200609/22_174317_fckeditor01.gif

「Open Editor"按後才打器界面
uploads/200609/22_174329_fckeditor02.gif

原理:使用JAVASCRIPT版的FCK,在面加(未打FCK),建一藏的TextArea域,TextArea的name和ID要和建的FCK例名一致,然後"Open Editor"按,通用一段函,使用FCK的ReplaceTextarea()方法建FCKeditor,代如下:
 <script type="text/javascript">
 <!--
 function showFCK(){
 var oFCKeditor = new FCKeditor( 'fbContent' ) ;
 oFCKeditor.BasePath = '/FCKeditor/' ;
 oFCKeditor.ToolbarSet = 'Basic' ;
 oFCKeditor.Width = '100%' ;
 oFCKeditor.Height = '200' ;
 oFCKeditor.ReplaceTextarea() ;
 }
 //-->
 </script>
 <textarea name="fbContent" id="fbContent">textarea>

2、使用FCKeditor 的 API
FCKeditor器,提供了非常富的API,用於End User很多想要定制的功能,比如最基本的,如何在提交的候用JS判前器域是否有容,FCK的API提供了GetLength()方法;

再比如如何通本向FCK插入容,使用InsertHTML()等;

有,在用定制功能,中步可能要行FCK的一些嵌操作,那就用ExecuteCommand()方法。

的API列表,查看FCKeditor的Wiki。而常用的API,查看FCK包的_samples/html/sample08.html。此就不代了。

3、外(多域共用一)
功能是2.3版本才始提供的,以前版本的FCKeditor要在同一面用多器的,得一建,在有了外功能,就不用那麻了,只需要把工具放在一的位置,後面就可以限制的建域了,如:
uploads/200609/22_174526_fckeditor03.gif

要功能呢,需要先在面中定一工具的容器:<divid="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

4、文件管理功能、文件上的限
一直以後FCKeditor的文件管理部分的安全是值得注意,但很多人注意到的地方,然FCKeditor在各Release版本中一直存在的一功能就是上文件型行,但是她考另一:到底允能上?到底能服器文件?

之前始用FCKeditor,我就出,好NetRube(FCKeditor中文化以及FCKeditor ASP版上程序的作者)及提醒了我,做法是去修改FCK上程序,在面行限判,且再在fckconfig.js把相的一些功能去掉。但之FCK版本的不升,每升一次都要去改一次配置程序fckconfig.js,我了,就什法能更好的控制配置?事上,是有的。

在fckconfig.js面,有於是否打上和服器的置,在建FCKeditor,通程序判是否建有上功能的器。首先,我先在fckconfig.js面把所有的上和置全false,接著我使用的代如下:

ASP版本:
<%
Dim oFCKeditor
Set oFCKeditor = New FCKeditor
with oFCKeditor
.BasePath = fckPath
.Config("ToolbarLocation") = "Out:fckToolBar"

if request.cookies(site_sn)("issuper")="yes" then
.Config("LinkBrowser") = "true"
.Config("ImageBrowser") = "true"
.Config("FlashBrowser") = "true"
.Config("LinkUpload") = "true"
.Config("ImageUpload") = "true"
.Config("FlashUpload") = "true"
end if
.ToolbarSet = "Basic"
.Width = "100%"
.Height = "200"

.Value = ""
.Create "jcontent"
%>

JAVASCRIPT版本:
 var oFCKeditor = new FCKeditor( 'fbContent' ) ;
 <%if power = powercode then%>
 oFCKeditor.Config['LinkBrowser'] = true ;
 oFCKeditor.Config['ImageBrowser'] = true ;
 oFCKeditor.Config['FlashBrowser'] = true ;
 oFCKeditor.Config['LinkUpload'] = true ;
 oFCKeditor.Config['ImageUpload'] = true ;
 oFCKeditor.Config['FlashUpload'] = true ;
 <%end if%>
 oFCKeditor.ToolbarSet = 'Basic' ;
 oFCKeditor.Width = '100%' ;
 oFCKeditor.Height = '200' ;
 oFCKeditor.Value = '' ;
 oFCKeditor.Create() ;
[最後於 Admin, at 2006-09-22 18:49:12]
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表