在线编辑器有很多种,但是这个 FCKeditor 是最受欢迎的。单纯的留言本开发没什么难度了。在这个基础上我在编辑器的概念也引入了进来。 很简单的一个例子,官方压缩包里有个文件夹 _samples 里面有很多调用的方法和实例,今天说一下我的。

假设文件目录结构是
\www
`````\test.php
\www\FCKeditor

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
    <head>
        <title>FCKeditor - Sample</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <meta name="robots" content="noindex, nofollow">
        <link href="./sample.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
   
<script type="text/javascript" src="
./FCKeditor/fckeditor.js"></script>
<script type="text/javascript">
window.onload = function()                        //
打开页面自动载入该函数
{
    var oFCKeditor = new FCKeditor( 'content' ) ; //
创建对象
    oFCKeditor.BasePath    = "
./FCKeditor/ " ;   // 主目录
    oFCKeditor.Height    = "380" ;                //
高度
    oFCKeditor.Value    = "" ;                    //
编辑框里的默认值
    oFCKeditor.Width    = "100%" ;                //
宽度
    oFCKeditor.ReplaceTextarea() ;                //
替换 testarea 文本
}   

</script>
   
        <h1>FCKeditor - PHP
调用实例 </h1>
       
方法以此类推,注意 FCKeditor 目录的位置
        <hr>
        <form action="test2.php" method="post" target="_blank">

<textarea name="content" style="width:620px" rows="10" id="content" ></textarea>


            <br>
            <input type="submit" value="Submit">
        </form>
    </body>
</html>

你可以再写一个 test2.php 来输出一下这个结果。内容很简单
<?php
echo $_POST["content"];
?>

需要注意的有两个地方: <script type="text/javascript" src=" ./FCKeditor/fckeditor.js "> oFCKeditor.BasePath    = " ./FCKeditor/ " ; 这两个相对路径的当前目录 ./ 绝对不能忽略。不信的话你删除一下试试就知道了。