fckeditor 使用笔记 - 调用

| No TrackBacks | Previous

  想把 fckeditor 放到 phpbb3 上面使用,遇到的第一个问题就是如何调用这个可视化的编辑器了。从网上找来一些资料,做了些小小的修改放到这里,以备日后参考:

  先看一下一段html代码:

<div id="message-box"> <textarea name="message" rows="15" class="inputbox"></textarea></div>

  方法一:覆盖现有的 textarea

<div id="message-box">
  <script type="text/javascript" src="fckeditor/fckeditor.js"></script>
  <script type="text/javascript">
    // <![CDATA[
    var fckeditor=new FCKeditor('message');
    fckeditor.BasePath="fckeditor/";// fckeditor 的路径
    fckeditor.ToolbarSet="Default";// fckeditor 使用的配置名称
    fckeditor.Width="100%";
    fckeditor.ReplaceTextarea();
    // ]]>
  </script>
<textarea name="message" rows="15" class="inputbox"></textarea></div>

  经过上面的修改,原本简单的文本框就被 fckeditor 取代了。

  方法二:使用JS调用

<div id="message-box">
  <script type="text/javascript" src="fckeditor/fckeditor.js"></script>
  <script type="text/javascript">
    var fckeditor=new FCKeditor('FCKEditor1');// 设置编辑器的名称
    fckeditor.BasePath="fckeditor/";
    fckeditor.Create();// 创建并且输出一个编辑器
  </script></div>

No TrackBacks

TrackBack URL: http://www.sothink.cn/cgi-bin/mt-tb.fpl/43

About this Entry

This page contains a single entry by SOTHINK published on October 22, 2009 2:31 PM.

您不能被重新授权为另一个用户 was the previous entry in this blog.

给Movable Type加上Meta Keyword和Description is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.