今天,我做了一个html在线编辑器,样子就是模仿的word里面的工具,代码很简单的,而且很实用。下面我给大家说一下。

    大家在网上搜索fckeditor的压缩包,下载好了以后解压出来,把它放到你的根目录里。接下来我们写下如下代码:

    <form action= "disp.php" method= "post"> <?php //引用FCKeditor.php这个文件,基本的类和数据结构都在这里 include ("fckeditor/fckeditor.php"); //创建FCKeditor对象的实例。myFCKeditor即提交后,接收数据页面 _POST['myFCKeditor']使用 $FCKeditor = new FCKeditor("content"); //FCKeditor所在的位置,这里它的位置就是'FCKeditor' 文件夹 $FCKeditor -> BasePath='./fckeditor/'; //工具按钮设置 $FCKeditor -> ToolbarSet="Default"; //设置它的宽度 $FCKeditor -> Width='500px'; //设置它的高度 $FCKeditor -> Height='300px'; //生成 $FCKeditor -> Create(); ?> <input type= "submit" value= "提交"> </form>      写完这段代码离成功就不远了,我们还要修改一下配置,就可以了。我们要找到fckeditor\editor\filemanager\connectors\php\ config.php在这个文件里大约30行左右,会有一段 $Config['Enabled'] = flase ;代码,将flase改为 true就可以了。我们还要在打开editor/filemanager/connectors/php目录下commands.php,找到FileUpload函数,在   $sExtension = substr( $sFileName, ( strrpos($sFileName, '.') + 1 ) ) ;   $sExtension = strtolower( $sExtension ) ; 后加上一句:    //解决中文乱码,把文件名重新命名(rename)    $sFileName = time().".".$sExtension; 这样一个完整而好用的在线编辑器就写好了,是不是很简单啊~~

更多推荐

html在线编辑器,模仿word,很简单很好用