只要把类似下面的代码加入视图,自动就把指定的 textarea 框变成编辑器了。
view plaincopy to clipboardprint?
1. <script language="javascript" type="text/javascript">
2. window.onload = function()
3. {
4. // body 是要转换的 textarea 的 id
5. var oFCKeditor = new FCKeditor('body') ;
6. oFCKeditor.BasePath = "/js/fckeditor/" ;
7. oFCKeditor.Height = 300;
8. oFCKeditor.Width = 500;
9. oFCKeditor.ReplaceTextarea() ;
10.
11. document.forms["form1"].onsubmit = function () {
12. // 确保提交时,编辑器的内容正确保存到表单字段中
13. var oEditor = FCKeditorAPI.GetInstance('body');
14. oEditor.SetHTML(data.body);
15. return true;
16. };
17. }
18. </script>
19. <script type="text/javascript" src="/js/fckeditor/fckeditor.js"></script>