首页 | 资讯动态 | linux基础 | 系统管理 | 网络管理 | 编程开发 | linux数据库 | 服务器技术 | linux相关 | linux认证 | 嵌入式 | 下载中心 | 专题 | linux招聘 | 镜像站
OKLinux中文技术站
·设为首页
·加入收藏
·联系我们
系统管理: 中文环境 系统管理 桌面应用 内核技术 | Linux基础: 基础入门 安装配置 常用命令 经验技巧 软件应用 | Linux数据库: Mysql Postgre Oracle DB2 Sybase other
网络管理: 网络安全 网络应用 Linux服务器 环境配置 黑客安全 | 编程开发: PHP CC++ Python Perl Shell 嵌入式开发 java jsp | PHP技术: PHP基础 PHP技巧 PHP应用 PHP文摘
Linux资讯 Linux招聘 Linux专题 Apache | Linux相关: 硬件相关 Linux解决方案 Linux认证 企业应用 其它Unix | 相关下载: 资料下载 参考手册 开发工具 服务器类 软路由 其它
 技术搜索:
会员中心 注册会员 高级搜索  
  → 当前位置:首页>编程开发>php>php技巧>正文

fckeditor用javascript创建

http://www.oklinux.cn  2006-07-28  来源:  qk31     会员收藏  游客收藏  【 】 

首先介绍如何用javascript创建fckeditor

//--------------------------------------------------------------------------------------------------

第一在头部有个引用:

CODE:
<script type="text/javascript" src="/FCKeditor/fckeditor.js"></script>
加入创建代码(创建的代码有多种形式)
第一种创建模式: 直接创建


CODE:
<script type="text/javascript">
var oFCKeditor = new FCKeditor('FCKeditor1');
oFCKeditor.BasePath = "/FCKeditor/";
oFCKeditor.Create();
</script>
第二种创建模式: 替换textarea

CODE:
<script type="text/javascript">
window.onload = function()
{
var oFCKeditor = new FCKeditor( 'MyTextarea' ) ;
oFCKeditor.BasePath = "/FCKeditor/" ;
oFCKeditor.ReplaceTextarea() ;
}
</script>
<textarea id="MyTextarea" name="MyTextarea">This is <b>the</b> initial value.</textarea>
在对于替换多个textArea时可以使用如下方法

CODE:
<html>
<head>
<title>Testing ReplaceAll()</title>

<script type="text/javascript" src="/FCKeditor/fckeditor.js"></script>

<script type="text/javascript">
<!--
function ReplaceAllTextareas() {
// replace all of the textareas
var allTextAreas = document.getElementsByTagName("textarea");
for (var i=0; i < allTextAreas.length; i++) {
var oFCKeditor = new FCKeditor( allTextAreas.name ) ;
oFCKeditor.BasePath = "/FCKeditor/" ;
oFCKeditor.ReplaceTextarea() ;
}
}
// -->
</script>

</head>

<body onLoad="javascript: ReplaceAllTextareas()">

<form>
<input type="checkbox" name="bobby" /> bobby <br />
<input type="checkbox" name="sue" /> sue <br />

Summary:
<textarea name="summary" rows="4" cols="80"> here is the summary </textarea>
Overview:
<textarea name="overview" rows="10" cols="80"> here is the overview </textarea>
Detials:
<textarea name="details" rows="60" cols="80"> here are teh details </textarea>

<input type="submit" name="sue" /> <br />
<input />
</form>

</body>
</html>
方法说明:

oFCKeditor.Width = 400 ; // 400 pixels

oFCKeditor.Width = "80%" ; // 80 percent

oFCKeditor.Height = 400 ; // 400 pixels

oFCKeditor.ToolbarSet = "MyToolbar" ;

oFCKeditor.Value = "<h1>Testing</h1>This is a <b>sample</b>." ;

oFCKeditor.BasePath = "/Components/FCKeditor/" ;

oFCKeditor.CheckBrowser = true ; //检查浏览器兼容性

oFCKeditor.DisplayErrors = false ; //转义editor显示错误信息


结合ajax使用fckeditor

//--------------------------------------------------------------------------------------------------


应用于ajax的时候可以考虑通过自带的例子sample08.html里面的函数GetContents结合使用

CODE:
function GetContents(fck)
{
        // Get the editor instance that we want to interact with.
        var oEditor = FCKeditorAPI.GetInstance(fck) ;

        // Get the editor contents in XHTML.
        return oEditor.GetXHTML( true )  ;                // "true" 表示执行格式化
}
url处理:

CODE:
fckeditor_value="fckeditor_value="+encodeURIComponent(GetContents("MyFCKeditor"))?//通过encodeURIComponent的javascript函数处理掉传参数里面出现各种不符字符

获取fckeditor里面的参数

提交:(这里使用的是prototype)


CODE:
new Ajax.Request("magsee.php",{method: 'post',parameters:fckeditor_value,onComplete:success_vote});
结果的获取magsee.php

CODE:
$_POST['fckeditor_value']



上一篇:SQLite数据库安全   下一篇:phplib7.2中文汉化版及调用示例


收藏于收藏夹】 【评论】 【推荐】 【打印】 【关闭
相关文档
·phplib7.2中文汉化版及调用示例
·SQLite数据库安全
·SQLite语法备忘录
·DOMXML: Expat之外的另一选择
·PHP.MVC的模板标签系统(一)
·玩转虚拟域名◎+
·PHP.MVC的模板标签系统(二)
·GD输出汉字的函数的分析
·最小化数据传输――在客户端存储数据
·PHP.MVC的模板标签系统(三)
·PHP.MVC的模板标签系统(四)
·php中的时间处理
·一段php加密解密的代码
·PHP.MVC的模板标签系统(五)
·将Oracle 10g内置的安全特性用于PHP
·PHP网站提速三大“软”招
发表评论
密码: 匿名评论
评论内容:

(不超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规)
 
  最新文档
·PHP之COOKIE支持详解
·PHP中的类
·php中文处理函数
·通过ODBC连接的SQL
·两个日期类
·面向对象编程
·面向过程与面向对象的简单比较
·判断WebSERVER类型
·屏蔽浏览器缓存另类方法
·日历类
·如何文档化你的PHP类
·使用PHP4中的 IntegratedTemplate类实
  阅读排行
·PHP之COOKIE支持详解
·PHP 应用程序配置模式
·用 PHP 读取文件的正确方法
·利用单元测试对PHP 代码进行检查
·五个常见 PHP 数据库问题
·用 PHP V4 开发的代码迁移到 PHP V5
·使用PHP 快速生成Flash 动画
·Linux系统下PHP服务器安全配置技巧
·Linux操作系统下的多线程编程详细解析
·用PHP读取和编写XML DOM
·用Pear加速PHP程序开发
·如何用PHP调用自己编写的COM组件?
·为 Linux 和 Windows 安装 PHP 和 Orac
·PHP面向对象编程快速入门
·终于实现简体转繁体,繁体到转体
网摘收藏: