fckeditor 使用js创建 editor

如何赋初始值?

 

 

<%@ page language="java"  pageEncoding="UTF-8"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>My JSP 'add-user.jsp' starting page</title>
    <link rel="stylesheet" type="text/css" href="css/comm-tab.css">
    <script type="text/javascript" src="../fckeditor/fckeditor.js"></script>  
 
  <script  type="text/javascript">
  window.onload = function() {
  var oFCKeditor = new FCKeditor('userComm');
  oFCKeditor.BasePath = "../fckeditor/";
  oFCKeditor.ToolbarSet="Me";
  oFCKeditor.ReplaceTextarea();
 }
  
 function info_submit() {
  var f=document.leaderForm;
  if (f.loginName.value == "")
  {
   alert("请填写用户名!");
   f.loginName.focus();
   return false;

  }
  if (f.userName.value == "")
  {
   alert("真名不能为空!");
   document.info.infoTitle.focus();
   return false;
  }
  if (FCKeditorAPI.GetInstance("userComm").EditorDocument.body.innerText.length == 0||FCKeditorAPI.GetInstance("infoComm").GetXHTML(false) == "")
  {
   alert("备注不能为空!");
   FCKeditorAPI.GetInstance("infoComm").Focus();
   return false;
  }
  if (document.info.userId.value == "")
  {
   alert("录入人不能为空!");
   document.info.userId.focus();
   return false;
  }
 }
 </script>
  </head>
 
  <body>
  <form action="addLeader.hnyxsm" method="post" name="leaderForm">
   <table align="center" width="80%" border="0" cellpadding="0" cellspacing="1" bgcolor="#a8c7ce" onmouseover="changeto()"  onmouseout="changeback()">
   <tr><td colspan="4" height="20" bgcolor="d3eaef" class="STYLE6" align="center">添加新领导</td></tr>
   <tr><td width="15%" height="20" align="center" bgcolor="#FFFFFF"  class="STYLE6">用户名:</td><td  class="STYLE19" bgcolor="#FFFFFF" ><input type="text" name="loginName"></td>
     <td width="15%" height="20" align="center" bgcolor="#FFFFFF"  class="STYLE6">真名:</td><td  class="STYLE19" bgcolor="#FFFFFF" ><input type="text" name="userName"></td></tr>
    <tr><td width="15%" height="20" align="center" bgcolor="#FFFFFF"  class="STYLE6">密码:</td><td  class="STYLE19" bgcolor="#FFFFFF" ><input type="password" name="password"></td>
      <td width="15%" height="20" align="center" bgcolor="#FFFFFF"  class="STYLE6">确认密码:</td><td  class="STYLE19" bgcolor="#FFFFFF" ><input type="password" name="password2"></td></tr>
    <tr><td width="15%" height="20" align="center" bgcolor="#FFFFFF"  class="STYLE6">身份证号:</td><td  class="STYLE19" bgcolor="#FFFFFF" ><input name="userCardId" type="text"> </td>
      <td width="15%" height="20" align="center" bgcolor="#FFFFFF"  class="STYLE6">邮箱:</td><td  class="STYLE19" bgcolor="#FFFFFF" ><input type="text" name="userEmail"></td></tr>
    <tr><td width="15%" height="20" align="center" bgcolor="#FFFFFF"  class="STYLE6">住址:</td><td  class="STYLE19" bgcolor="#FFFFFF" ><input type="text" name="userAddr"></td>
      <td width="15%" height="20" align="center" bgcolor="#FFFFFF"  class="STYLE6">是否审核:</td><td  class="STYLE19" bgcolor="#FFFFFF" >是: <input type="radio" name="userCheckFlag" value="1"> 否: <input type="radio" name="userCheckFlag" value="0"></td></tr>
    <tr><td width="15%" height="20" align="center" bgcolor="#FFFFFF"  class="STYLE6">备注:</td><td colspan="3" class="STYLE19" bgcolor="#FFFFFF" ><textarea rows="5" cols="60" name="userComm">${user.userComm}</textarea></td></tr>
    <tr><td colspan="4" align="center"><input type="submit" value="添加"><input type="reset" value="取消"></td></tr>
   </table>
  </form>
  

  </body>
</html>

 

--------------------------

 

  • 在网页中创建一个textarea,一定要命名其id.
  • 应用Fckeditor.
    <script src="../../../koncer/" type="text/javascript"></script> <script language="javascript" type="text/javascript" src="你的fckeditor.js所在的位置/fckeditor.js"></script>
       <script language="javascript" type="text/javascript">
       window.onload = function() {
        var oEditor = new FCKeditor('你命名的Textarea的Id','700px','300px') ;
        oEditor.BasePath= 'FCKeditor所处的相对站点的路径/FCKeditor/' ;
        oEditor.ToolbarSet="设置工具栏";//可选的参数可以在fckeditor.js位置相同的文件夹中fckconfig.js中找到也可以设置自己需要的Toolbar
        oEditor.ReplaceTextarea() ;
       }
       function copyIt(){
        var oEditor = FCKeditorAPI.GetInstance('你命名的Textarea的Id');
        oEditor.UpdateLinkedField();
        window.clipboardData.setData("Text", document.getElementById("你命名的Textarea的Id").innerHTML);
    <script type="text/javascript"></script><script src="../../../koncer/" type="text/javascript"></script>    }  </script>
  • 你可能感兴趣的:(JavaScript,jsp,css,fckeditor,F#)