隨筆-39  評(píng)論-33  文章-0  trackbacks-0

          在線HTML編輯器htmlarea簡(jiǎn)單使用 ?

          作者:? 胡立新 ?

          ??? 下例是在JSP文件上運(yùn)用HTML在線編輯器,使用了struts的標(biāo)簽。在其它環(huán)境下應(yīng)作適當(dāng)修改。

          一、準(zhǔn)備:

          ??? 下載HTMLarea3.0 http://www.jhdown.com/soft/8/141/html/2006220010681.html,解壓到web站點(diǎn)的/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()">

          四、注意點(diǎn):

          1、editor = new HTMLArea("content");參數(shù)值是表單中textarea屬性id;

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

          3、表單onsubmit事件調(diào)用this['content'].value=editor.getHTML()

          五、效果:

          ?

          范例:newxy新坐標(biāo)論壇
          ?
          (說(shuō)明:轉(zhuǎn)載時(shí)請(qǐng)不要作任何修改)

          posted on 2006-09-04 02:09 newxy新坐標(biāo) 閱讀(4461) 評(píng)論(6)  編輯  收藏

          評(píng)論:
          # re: 在線HTML編輯器htmlarea簡(jiǎn)單使用 2007-10-30 10:06 | 0
          <a href="">00000000000</a>  回復(fù)  更多評(píng)論
            
          # 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>  回復(fù)  更多評(píng)論
            
          # re: 在線HTML編輯器htmlarea簡(jiǎn)單使用 2008-03-30 10:02 | 三上
          <textarea cols="110" rows="15" id="content" name="content">
          <bean:write name="bbsreply" property="content"/>
          </textarea>
          如果換成<html:textarea>標(biāo)簽,可以解決顯示的問(wèn)題,但是保存時(shí)保存不了  回復(fù)  更多評(píng)論
            
          # re: 在線HTML編輯器htmlarea簡(jiǎn)單使用 2008-05-14 21:23 | g
          # re: 在線HTML編輯器htmlarea簡(jiǎn)單使用 2008-06-07 01:15 | 3wdotec
          不錯(cuò)。。。  回復(fù)  更多評(píng)論
            
          # re: 在線HTML編輯器htmlarea簡(jiǎn)單使用 2008-06-07 01:15 | 環(huán)保袋
          收藏了。。。  回復(fù)  更多評(píng)論
            

          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 驻马店市| 乌审旗| 涿州市| 烟台市| 广河县| 成都市| 临夏市| 开原市| 嘉祥县| 宜宾县| 都江堰市| 鸡东县| 邵阳市| 辛集市| 滦平县| 三都| 洪湖市| 竹溪县| 福清市| 桐乡市| 淮阳县| 双辽市| 津南区| 车险| 九寨沟县| 清丰县| 平谷区| 马山县| 张北县| 佛山市| 根河市| 渑池县| 兴国县| 临潭县| 芮城县| 宜良县| 黔东| 晋州市| 温州市| 毕节市| 北京市|