在線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新坐標 閱讀(4456)
評論(6) 編輯 收藏