var FCKTemplate = new FCKTemplate();
function FCKTemplate(){
/*初始化*/
FCKTemplate.prototype.newInstance = function(instanceName, templateName){
var oFCKeditor = new FCKeditor(instanceName);
oFCKeditor.BasePath = "/fckeditor/";
oFCKeditor.ToolbarSet = templateName;
oFCKeditor.Config["CustomConfigurationsPath"]="/fckeditor/myconfig.js";
oFCKeditor.ReplaceTextarea();
return oFCKeditor;
};
/*获取XHTML*/
FCKTemplate.prototype.getXHTML = function(instanceName){
return encodeURIComponent(FCKeditorAPI.GetInstance(instanceName).GetXHTML());
};
/*清空一个对象*/
FCKTemplate.prototype.clear = function(instanceName){
FCKeditorAPI.GetInstance(instanceName).SetHTML("", false);;
};
/*设置一个对象*/
FCKTemplate.prototype.setHTML = function(instanceName,html){
FCKeditorAPI.GetInstance(instanceName).SetHTML(html, false);;
};
/*获得焦点*/
FCKTemplate.prototype.focus = function(_instanceName){
FCKeditorAPI.GetInstance(_instanceName).Focus();
};
/*创建新oFCKeditor*/
FCKTemplate.prototype.getInstance = function(instanceName, templateName){
var oFCKeditor = FCKeditorAPI.GetInstance(instanceName);
if (oFCKeditor == null || oFCKeditor == undefined) {
oFCKeditor = new FCKeditor(instanceName);
oFCKeditor.BasePath = "/fckeditor/";
oFCKeditor.ToolbarSet = templateName;
oFCKeditor.Config["CustomConfigurationsPath"]="/fckeditor/myconfig.js";
oFCKeditor.Height=300;
oFCKeditor.ReplaceTextarea();
return oFCKeditor;
}else{
return ;
}
};
/*ajax 创建fckeditor*/
FCKTemplate.prototype.createHtml = function(instanceName, templateName , elementId){
var div = document.getElementById(elementId);
var oFCKeditor = new FCKeditor(instanceName);
oFCKeditor.BasePath = "/fckeditor/";
oFCKeditor.ToolbarSet = templateName;
div.innerHTML = oFCKeditor.CreateHtml();
} Add myconfig.js in fckeditor
FCKConfig.AutoDetectLanguage = false ; FCKConfig.DefaultLanguage = "zh-cn" ; FCKConfig.ToolbarSets["mydefault"] = [ ['Source','FitWindow','Preview','-','Paste','PasteText','PasteWord','-'], ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'], ['Bold','Italic','Underline','StrikeThrough'], ['OrderedList','UnorderedList','-','Outdent','Indent'], ['JustifyLeft','JustifyCenter','JustifyRight','JustifyFull'], '/', ['Style','FontFormat','FontName','FontSize'], ['TextColor','BGColor'], ['Link','Unlink','Image','Flash','SpecialChar','PageBreak'], ]; FCKConfig.ToolbarSets["resourcedefault"] = [ ['Source','FitWindow','Preview','-','Paste','PasteText','PasteWord','-'], ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'], '/', ['Style','FontFormat','FontName','FontSize'], ['TextColor','BGColor'], ['Link','Unlink','Image','Flash','SpecialChar'], ];
Configuration file to increase the end
Amending fckconfig.js
FCKConfig.CustomConfigurationsPath = 'myconfig.js'; configuration mode fck
FCKConfig.EditorAreaCSS = FCKConfig.BasePath + 'css / fck_editorarea.css'; configuration shows the path
Increase in the web.xml
<servlet>
<servlet-name> Connector </ servlet-name>
<servlet-class> net.fckeditor.connector.ConnectorServlet </ servlet-class>
<init-param>
<param-name> baseDir </ param-name>
<param-value> / UserFiles / </ param-value>
</ init-param>
<init-param>
<param-name> debug </ param-name>
<param-value> false </ param-value>
</ init-param>
<load-on-startup> 1 </ load-on-startup>
</ servlet>
<servlet-mapping>
<servlet-name> Connector </ servlet-name>
<url-pattern>
/ fckeditor / editor / filemanager / connectors / *
</ url-pattern>
</ servlet-mapping>
Note here the different versions of fck, package name is not the same as net.fckeditor.connector.ConnectorServlet error Please note, if modified
Please note that if you are using fck modify configuration struts2.0
<filter-mapping>
<filter-name> struts2 </ filter-name>
<url-pattern> *. action </ url-pattern>
</ filter-mapping>
<filter-mapping>
<filter-name> struts2 </ filter-name>
<url-pattern> *. jsp </ url-pattern>
</ filter-mapping>
<filter-mapping>
<filter-name> struts2 </ filter-name>
<url-pattern> *. ftl </ url-pattern>
</ filter-mapping>
As far as possible the name of the specified suffixes, If you do not specify the conflict will be
The introduction of the use of fck.js page
Way call: <textarea name='te' align="left" />
<script type="text/javascript">
var fck = FCKTemplate.newInstance ( "te", "resourcedefault");
fck.EnableSourceXHTML = true;
</ script>







