【www.gdgbn.com--网页配色】

fckeditor配置与增加中字体方法
假设网站的目录为:

以下为引用的内容:

website_root
index.php教程
fckeditor 


一、调用fckeditor 的两种方法

1、通过创建实例来调用

在 index.php 文件中,调用它的代码,把下面的代码加在需要编辑器的地方:

以下为引用的内容:


//引用fckeditor.php这个文件,基本的类和数据结构都在这里
include_once("fckeditor/fckeditor.php");
//创建fckeditor对象的实例。myfckeditor即提交后,接收数据页面 _post["myfckeditor"]使用
fckeditor=new fckeditor("myfckeditor");
//fckeditor所在的位置,这里它的位置就是"fckeditor" 文件夹
fckeditor->basepath="./fckeditor/";
//工具按钮设置
fckeditor->toolbarset="default";
//设置它的宽度
fckeditor->width="100%";
//设置它的高度
fckeditor->height="300px";
//生成
fckeditor->create();
?>
 


2、通过 iframe 调用

以下为引用的内容:





 


注意:name="myfckeditor" 和 iframe 中 instancename=myfckeditor 的“myfckeditor”必须相同。

其实,用 iframe 调用和用第一种方法本质是完全一样的!不信的话,请在用浏览器打开网站上的 index.php 文件,然后查看“源代码”,就是本 iframe 调用的代码。所以推荐通过创建实例来调用。

3、当用 网页特效 来获得内容的时候是不是发现得不到内容,如:
<script>

</script>
你会发现弹谈出的窗口没内容。

我们可以通过下面的代码来获得它的内容:

以下为引用的内容:

<script>
function getcontentvalue()
{
var oeditor = fckeditorapi.getinstance("myfckeditor");
var acontent = oeditor.getxhtml();
return acontent;
}
</script>
 

fckeditor增加中文字体,并在编辑器中显示效果


fckeditor在进行文本编辑时,无法使用中文字体。

自个摸索了下:

打开 fckconfig.js 文件
找到第154行(应该是),会发现:
fckconfig.fontnames = "arial;comic sans ms;courier new;tahoma;times new roman;verdana" ;
将其修改为:
fckconfig.fontnames = "宋体;黑体;幼圆;楷体_gb2312;仿宋_gb2312;arial;comic sans ms;courier new;tahoma;times new roman;verdana" ;

当当这样还是不行,虽然发现编辑器的字体选项多了已添加的中文字体,但应用到文本上却发现没有任何作用!
接着下一步 :)


打开editor/css教程/fck_editorarea.css 文件

将:
font-family: arial, verdana, sans-serif;
修改为:
font-family: 宋体, 黑体, 幼圆, 楷体, 仿宋, arial, verdana, sans-serif;

本文来源:http://www.gdgbn.com/wangyezhizuo/29623/