0
今天,我第一次遇到了YUI 2 Rich Text Editor
。 (http://developer.yahoo.com/yui/editor/)Yahoo YUI 2 - 富文本編輯器 - 無法獲取setEditorHTML方法的工作,出了什麼問題?
我主要使用Java服務器頁面爲我的網站。
我希望能夠將編輯器的textarea中的文本設置爲以前提交的值。例如,當用戶提交頁面時,在編輯器中輸入文本後,該文本可能會保存在數據庫中供將來使用。然後,我會調用數據庫中的值,並將編輯器設置爲在此時顯示它,以便用戶可以進行修改。
我在API文檔中找到了一個名爲setEditorHTML()
的方法 - 但由於某種原因,我無法使其工作。
這是我一直在玩的測試代碼。我正在Firefox中測試。
我不明白爲什麼setEditorHTML
方法不起作用...有人可以幫助我嗎?
<html>
<head>
<% String editorText = (String)session.getAttribute("editorText"); %>
<!-- Individual YUI CSS files -->
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.9.0/build/assets/skins/sam/skin.css">
<!-- Individual YUI JS files -->
<script type="text/javascript" src="http://yui.yahooapis.com/2.9.0/build/yahoo-dom-event/yahoo-dom-event.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.9.0/build/element/element-min.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.9.0/build/container/container_core-min.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.9.0/build/menu/menu-min.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.9.0/build/button/button-min.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.9.0/build/dragdrop/dragdrop-min.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.9.0/build/slider/slider-min.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.9.0/build/colorpicker/colorpicker-min.js"></script>
<script type="text/javascript" src="Yahoo-YUI-editor/editor-min.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.9.0/build/layout/layout-min.js"></script>
<script language="javascript">
var myEditor = new YAHOO.widget.Editor('msgpost', {
height: '300px',
width: '522px',
dompath: false, //Turns on the bar at the bottom
animate: false, //Animates the opening, closing and moving of Editor windows
handleSubmit: true
});
myEditor.render();
<% if(editorText != null) {
out.print("myEditor.setEditorHTML(\""+editorText+"\");");
}
%>
</script>
</head>
<body class="yui-skin-sam">
<form name="editor" action="YahooEditor.jsp" method="post">
<textarea name="msgpost" id="msgpost" cols="50" rows="10"></textarea>
<input type="submit" value="submit"/>
</form>
</body>
</html>
謝謝你,工作! – katura