FCKeditor JS Verification

Source: Internet
Author: User

In JS, the value is as follows:

Javascript Code
    1. VaRCheckcontent = fckeditorapi. getinstance ("Content"). Getxhtml ();

In addition, let the editor get the focus:

JavaScript code
    1. VaROeditor = fckeditorapi. getinstance ('Content');
    2. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.