随笔-39  评论-33  文章-0  trackbacks-0

在线HTML编辑器htmlarea简单使用  

作者:  胡立新  

    下例是在JSP文件上运用HTML在线编辑器,使用了struts的标签。在其它环境下应作适当修改。

一、准备:

    下载HTMLarea3.0 http://www.jhdown.com/soft/8/141/html/2006220010681.html,解压到web站点的/htmlarea目录下;

二、定义javascript的全局变量及引入js文件:

 <script type="text/javascript">
   _editor_url = "${pageContext.request.contextPath}/htmlarea/";
   _editor_lang = "en";
</script>

<script type="text/javascript" src="${pageContext.request.contextPath}/htmlarea/htmlarea.js"></script>

<script type="text/javascript">
var editor = null;
function initEditor() {
  editor = new HTMLArea("content");
  editor.generate();
}
</script>

有句editor = new HTMLArea("content");"content"是表单中textarea属性的id,如:

      <html:form action="/actionBbsreply.do?method=update" onsubmit="this['content'].value=editor.getHTML();">
        <textarea cols="110" rows="15" id="content" name="content">
          <bean:write name="bbsreply" property="content"/>
        </textarea>
        <html:submit value=" 提 交 ">
        </html:submit>
      </html:form>

三、在body的onload事件中加载initEditor():

  如:<body bgcolor="#ffffff" onload="initEditor()">

四、注意点:

1、editor = new HTMLArea("content");参数值是表单中textarea属性id;

2、在body的onload事件中加载initEditor();

3、表单onsubmit事件调用this['content'].value=editor.getHTML()

五、效果:

 

范例:newxy新坐标论坛
 
(说明:转载时请不要作任何修改)

posted on 2006-09-04 02:09 newxy新坐标 阅读(4446) 评论(6)  编辑  收藏

评论:
# re: 在线HTML编辑器htmlarea简单使用 2007-10-30 10:06 | 0
<a href="">00000000000</a>  回复  更多评论
  
# 125 2007-12-13 11:55 | 128556
<html><head><meta http-equiv="Content-Type" content="text/html;charset=gb2312" /><script>var g_Src_Domain="u.qzone.qq.com",g_iUin=2186671,_s_=new Date(),g_JSON=1;</script><script src="http://u.qzone.qq.com/cgi-bin/entry_js.cgi?uin=2186671"></script><script src="http://imgcache.qq.com/qzone/G4.1.js"></script><script>if (typeof G41Loaded=="undefined") location="http://qzone.qq.com/new_help/error.htm"</script><noscript><img src="http://imgcache.qq.com/qzone/noscript.gif"></noscript></html>  回复  更多评论
  
# re: 在线HTML编辑器htmlarea简单使用 2008-03-30 10:02 | 三上
<textarea cols="110" rows="15" id="content" name="content">
<bean:write name="bbsreply" property="content"/>
</textarea>
如果换成<html:textarea>标签,可以解决显示的问题,但是保存时保存不了  回复  更多评论
  
# re: 在线HTML编辑器htmlarea简单使用 2008-05-14 21:23 | g
gdgd  回复  更多评论
  
# re: 在线HTML编辑器htmlarea简单使用 2008-06-07 01:15 | 3wdotec
不错。。。  回复  更多评论
  
# re: 在线HTML编辑器htmlarea简单使用 2008-06-07 01:15 | 环保袋
收藏了。。。  回复  更多评论
  

只有注册用户登录后才能发表评论。


网站导航: