网络编程
位置:首页>> 网络编程>> JavaScript>> HTML编辑器FCKeditor使用详解(2)

HTML编辑器FCKeditor使用详解(2)

作者:FastUnit 来源:Java快速开发平台 发布时间:2010-02-28 12:30:00 

标签:FCKeditor,编辑器,html编辑器

四、使用

本例使用最直接的js方式,API和TagLib方式参见FCKeditor-2.3.zip解压后_samples下的例子。

fckdemo.jsp: 


<%@    page contentType="text/html;charset=GBK"%>
<html>
<head>
<title>FCKeditor Test</title>
<script type="text/javascript" src="/fckeditor/fckeditor.js"></script>
</head>
<body>
<form action="fckdemo.jsp" method="post">

<% 
String content=request.getParameter("content");
if (content != null) {
  content = content.replaceAll("\r\n", "");
  content = content.replaceAll("\r", "");
  content = content.replaceAll("\n", "");
  content = content.replaceAll("\"", "'");
}else{
  content = "";
}
%>

<table width=100%>
<tr>
    <td colspan=4 style='text-align:center' width=100% height=50px>
    <span>
        <script type="text/javascript">
            var oFCKeditor = new FCKeditor('content');//传入参数为表单元素(由FCKeditor生成的input或textarea)的name
            oFCKeditor.BasePath='/fckeditor/';//指定FCKeditor根路径,也就是fckeditor.js所在的路径
            oFCKeditor.Height='100%';
            oFCKeditor.ToolbarSet='Demo';//指定工具栏
            oFCKeditor.Value="<%=content%>";//默认值
            oFCKeditor.Create();
        </script>
    </span>
    </td>
</tr>
<tr><td align=center><input type="submit" value="提交"></td></tr>
<tr><td>&nbsp;</td></tr>
<tr><td>取值(可直接保存至数据库):</td></tr>
<tr><td style="padding:10px;"><%=content%></td></tr>
</table>

</form>
</body>
</html> 

效果图:

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com