- 
							用js给fckeditor赋值、取值的办法普通类
- 
							- 支持
- 批判
- 提问
- 解释
- 补充
- 删除
 
- 
							- 
													用js给fckeditor赋值、取值的办法
 //获取编辑器中HTML内容 
 function getEditorHTMLContents(EditorName)
 {
 var oEditor = FCKeditorAPI.GetInstance(EditorName);
 return(oEditor.GetXHTML(true));
 }
 //获取编辑器中文字内容
 function getEditorTextContents(EditorName)
 {
 var oEditor = FCKeditorAPI.GetInstance(EditorName);
 return(oEditor.EditorDocument.body.innerText);
 }
 //设置编辑器中内容
 function SetEditorContents(EditorName, ContentStr)
 {
 var oEditor = FCKeditorAPI.GetInstance(EditorName) ;
 oEditor.SetHTML(ContentStr) ;
 }
 赋值:
 Java代码
 var oEditor = FCKeditorAPI.GetInstance('ncontent');
 oEditor.SetHTML(“三菱电机法拉撕开对方”);
 还有一个使用的是jquery来实现
 jQuery FCKEditor插件取值、赋值
 2008-12-13 16:51
 第一步:导入需要的js文件(根据实际情况修改相应路径)
 Java代码
 <script src="../js/jquery.js" type=text/javascript></script>
 <script src="../js/jquery.FCKEditor.js" type=text/javascript></script>
 <script src="../fckeditor/fckeditor.js" type="text/javascript"></script>
 <script src="../js/jquery.js" type=text/javascript></script>
 <script src="../js/jquery.FCKEditor.js" type=text/javascript></script>
 <script src="../fckeditor/fckeditor.js" type="text/javascript"></script>
 第二步:初始化(根据实际情况修改相应路径)
 Java代码
 //初始化FCKEditor
 $.fck.config = {path: '/这里是你的项目名称/fckeditor/', height: 400 ,toolbar:'Default'};
 $('textarea#ncontent').fck();
 //初始化FCKEditor
 $.fck.config = {path: '/这里是你的项目名称/fckeditor/', height: 400 ,toolbar:'Default'};
 $('textarea#ncontent').fck();
 其中#ncontent为页面你所绑定的textArea的id或name
 第三步:取值
 Java代码
 var getcontent = $.fck.content('ncontent', ''); //其中ncontent为页面你所绑定的textarea的id或name
 var getcontent = $.fck.content('ncontent', ''); //其中ncontent为页面你所绑定的textarea的id或name
 第四步:赋值(更新的时候先把原有的值赋给textarea)
 Java代码
 var oEditor = FCKeditorAPI.GetInstance('ncontent');
 oEditor.SetHTML(data.news_add.na_newscontent);
 来自:http://hi.baidu.com/cicon/blog/item/37a42097b2dbdb7d55fb9684.html 
- 
													
- 
							- 标签:
- 赋值
- java
- fckeditor
- 代码
- 39
- js
- fckeditorapi.getinstance
- text
- varoeditor
- 取值
- javascript
- editorname
 
- 
				
				
				
 
			 
		 
	 
								 
								 
						
学习元评论 (0条)
聪明如你,不妨在这 发表你的看法与心得 ~