利用javascripte使用FCKEditor

利用javascripte使用fckeditor的方法如下:
前提是已经将解压后的fckeditor文件复制到项目的根目录下
一,不使用覆盖textarea的方法,直接在body中写js代码创建fckeditor的实例
步骤1.
在head标签之间引用fckeditor的js
<scripte type="text/javascripte" src="fckeditor/fckeditor.js" />


步骤2.
在<body>任意你想使用fckeditor的地方写一下js代码
<script>
   var fck = new FCKeditor("test") ;
   fck.BasePath = "/你的项目名称/fckeditor[color=red]/[/color]" ;
   fck.Width = "" ;
   fck.Height = "" ;
   fck.ToolbarSet = "" ;
   fck.Value = "" ;
   fck.Create() ;
</script>


其中的属性值可以自己指定

二.使用覆盖textarea 的方法
步骤1.
同方法一中的步骤1,因为必须要引用fckeditor的js代码

步骤二.
在<head>标签中插入以下代码,可以在浏览器启动时用fckeditor覆盖相应名称的textarea
<script>
    window.onload = function() 
    {
        var fck = new FCKeditor("test") ;
        fck.BasePath = "/你的项目名称/fckeditor[color=red]/[/color]" ;
        fck.Width = "" ;
        fck.Height = "" ;
        fck.ToolbarSet = "" ;
        fck.Value = "" ;
        fck.ReplaceTextarea() ;
    }
</script>


其中的属性值可以自己指定

步骤3.
步骤2中的代码将会覆盖body中的以下textarea
<textarea row="5" col="30" name="test"></textarea>
这里主要根据textarea的名字来区分,找到对应的textarea并覆盖

你可能感兴趣的:(浏览器,fckeditor)