注册 | 登录 忘记密码? 51cto首页 | 博客 | 论坛 | 招聘
热点文章 IB客座主编(四)美国西蒙公..
 帮助

[伊达原创]实战FCKeditor在线编辑器


2007-07-20 22:16:20
 标签:PHP 编辑器 FCKeditor   [推送到技术圈]

版权声明:原创作品,如需转载,请与作者联系。否则将追究法律责任。
在线编辑器有很多种,但是这个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/" ; 这两个相对路径的当前目录./绝对不能忽略。不信的话你删除一下试试就知道了。

本文出自 “Linux学习工坊” 博客,转载请与作者联系!


附件下载:
  NT版本




    文章评论
 
2007-07-21 19:08:01
哈哈,编辑器,不错。
我先试去

 

发表评论

昵   称:
验证码:  点击图片可刷新验证码  博客过2级,无需填写验证码
内   容: