在JS裏取值方法如下:
- var checkContent =FCKeditorAPI.GetInstance("content").GetXHTML();
另外還要讓編輯器獲得焦點:
- var oEditor = FCKeditorAPI.GetInstance('content');
- oEditor.Focus();
注意這裏的Focus()是大寫。
=======================================================
function validateForm() {
var title = document.getElementById('infoAnnounce.title').value;
var oEditor = FCKeditorAPI.GetInstance('infoAnnounce.content');
if (title == '') {
alert("標題不能爲空");
return false;}
else if(title.substring(0,1)==" ")
{ alert("第一個字符不能爲空格!");
return false;}
else if(oEditor.GetXHTML(true) == "" ) {
alert('內容不能爲空!');
return false;}
return true;
}
在JS裏取值方法如下:var checkContent =FCKeditorAPI.GetInstance("content").GetXHTML();
長度驗證:FCKeditorAPI.GetInstance("content").GetXHTML().length;
另外還要讓編輯器獲得焦點:var oEditor = FCKeditorAPI.GetInstance('content');oEditor.Focus();
FCK 編輯器加載後,將會註冊一個全局的 FCKeditorAPI 對象. FCKeditorAPI 對象在頁面加載期間是無效的,直到頁面加載完成.如果需要交互式地知道 FCK 編輯器已經加載完成,可使用"FCKeditor_OnComplete"函數.
<script type="text/javascript">
function FCKeditor_OnComplete(editorInstance) {
FCKeditorAPI.GetInstance('FCKeditor1').Commands.GetCommand('FitWindow').Execute();
}
</script>
在當前頁獲得FCK 編輯器實例: var oEditor = FCKeditorAPI.GetInstance('InstanceName');
從 FCK 編輯器的彈出窗口中獲得FCK 編輯器實例: var oEditor = window.parent.InnerDialogLoaded().FCK;
從框架頁面的子框架中獲得其它子框架的FCK 編輯器實例: var oEditor = window.FrameName.FCKeditorAPI.GetInstance('InstanceName');
從頁面彈出窗口中獲得父窗口的FCK 編輯器實例: var oEditor = opener.FCKeditorAPI.GetInstance('InstanceName');
獲得FCK 編輯器的內容: oEditor.GetXHTML(formatted); // formatted 爲:true|false,表示是否按HTML格式取出也可用: oEditor.GetXHTML();
設置FCK 編輯器的內容: oEditor.SetHTML("content", false); // 第二個參數爲:true|false,是否以所見即所得方式設置其內容.此方法常用於"設置初始值"或"表單重置"操作.
插入內容到FCK 編輯器: oEditor.InsertHtml("html"); // "html"爲HTML文本
檢查FCK 編輯器內容是否發生變化: oEditor.IsDirty();
在 FCK 編輯器之外調用FCK 編輯器工具條命令, 命令列表如下:
DocProps, Templates, Link, Unlink, Anchor, BulletedList, NumberedList, About, Find, Replace, Image, Flash, SpecialChar, Smiley, Table, TableProp, TableCellProp, UniversalKey, Style, FontName, FontSize, FontFormat, Source, Preview, Save, NewPage, PageBreak, TextColor, BGColor, PasteText, PasteWord, TableInsertRow, TableDeleteRows, TableInsertColumn, TableDeleteColumns, TableInsertCell, TableDeleteCells, TableMergeCells, TableSplitCell, TableDelete, Form, Checkbox, Radio, TextField, Textarea, HiddenField, Button, Select, ImageButton, SpellCheck, FitWindow, Undo, Redo
<script type="text/javascript"></script>