In JS, the value is as follows:
Javascript Code
- VaRCheckcontent = fckeditorapi. getinstance ("Content"). Getxhtml ();
In addition, let the editor get the focus:
JavaScript code
- VaROeditor = fckeditorapi. getinstance ('Content');
- Oeditor. Focus ();
Note that the focus () Here is in uppercase.
========================================================== ====================
Function validateform (){
VaR Title = Document. getelementbyid ('infoannounce. title'). value;
VaR oeditor = fckeditorapi. getinstance ('infoannounce. content ');
If (Title = ''){
Alert ("title cannot be blank ");
Return false ;}
Else if (title. substring (0, 1) = "")
{Alert ("the first character cannot be a space! ");
Return false ;}
Else if (oeditor. getxhtml (true) = ""){
Alert ('content cannot be blank! ');
Return false ;}
Return true;
}
In JS, the value can be as follows: var checkcontent = fckeditorapi. getinstance ("content"). getxhtml ();
Length verification: fckeditorapi. getinstance ("content"). getxhtml (). length;
In addition, let the editor get the focus: var oeditor = fckeditorapi. getinstance ('content'); oeditor. Focus ();
After the fck editor is loaded, a global fckeditorapi object will be registered. the fckeditorapi object is invalid during page loading until the page loading is complete. if you need to interactively know that the fck editor has been loaded, you can use the "fckeditor_oncomplete" function.
<SCRIPT type = "text/JavaScript">
Function fckeditor_oncomplete (editorinstance ){
Fckeditorapi. getinstance ('fckeditor1'). commands. getcommand ('fitwindow'). Execute ();
}
</SCRIPT>
On the current page, obtain the fck editor instance: var oeditor = fckeditorapi. getinstance ('instancename ');
Obtain the fck editor instance from the pop-up window of the fck Editor: var oeditor = Window. Parent. innerdialogloaded (). fck;
Obtain the fck editor instance of other sub-frameworks from the sub-frameworks on the Framework page: var oeditor = Window. framename. fckeditorapi. getinstance ('instancename ');
Obtain the fck editor instance of the parent window from the pop-up window: var oeditor = opener. fckeditorapi. getinstance ('instancename ');
Get the fck editor content: oeditor. getxhtml (formatted); // formatted: True | false, indicating whether to retrieve data in HTML format. oeditor. getxhtml ();
Set the content of the fck Editor: oeditor. sethtml ("content", false); // The second parameter is true | false. Whether to set the content in WYSIWYG mode. this method is often used for "set initial value" or "form RESET" operations.
Insert content to the fck Editor: oeditor. inserthtml ("html"); // "html" is HTML text
Check whether the fck editor content has changed: oeditor. isdirty ();
Call the fck editor toolbar Command outside the fck editor. The command list is as follows:
Docprops, templates, Link, unlink, anchor, random, 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, delimiter, tabledeletecolumns, delimiter, tabledeletecells, delimiter, tablesplitcell, tabledelete, form, checkbox, radio, textfield, textarea, hiddenfield, button, select, imagebutton, spellcheck, fitwindow, undo, redo