FCKEDITOR advanced features and solutions for Frequently Asked Questions _ Web page Editor

Source: Internet
Author: User
It can be combined with different programming languages such as PHP, JavaScript, ASP, ASP.net, ColdFusion, Java, and ABAP. FCK configuration and use are simple, but the default configuration does not meet all requirements, so we need to know some FCK advanced features.

Get an instance of FCK
Fckeditorapi is a global object that is registered after FCKeditor is loaded, and we can use it to complete various operations on the editor.
Get FCK Editor Instance on current page:
var Editor = fckeditorapi.getinstance (' instancename ');
Get the FCK editor instance from the pop-up window of the FCK editor:
var Editor = window.parent.InnerDialogLoaded (). FCK;
To obtain a FCK editor instance of another child frame from a child frame of a frames page:
var Editor = window. FrameName.FCKeditorAPI.GetInstance (' instancename ');
To get the FCK editor instance of the parent window from the page pop-up window:
var Editor = opener. Fckeditorapi.getinstance (' instancename ');

FCK Get Focus
Gets whether the focus is in FCK:
Oeditor.hasfocus
FCK Get Focus:
Oeditor.focus ()//Get focus

Get and set the contents of FCK
Get the contents of the FCK Editor:
oeditor.getxhtml (formatted); Formatted is: True|false, which indicates whether to be removed in HTML format.

To set the contents of the FCK Editor:
oeditor.sethtml ("content", false); The second parameter is: True|false, whether the contents are set in WYSIWYG mode.

To insert content into the FCK editor:
oeditor.inserthtml ("HTML"); "HTML" as HTML text

Check if the contents of the FCK editor have changed:
Oeditor.isdirty ();
Copy Code code as follows:

Get HTML content in editor
function Geteditorhtmlcontents (editorname) {
var oeditor = fckeditorapi.getinstance (editorname);
Return (Oeditor.getxhtml (true));
}

Get text in Editor
function Geteditortextcontents (editorname) {
var oeditor = fckeditorapi.getinstance (editorname);
return (OEditor.EditorDocument.body.innerText);
}

Setting the contents of the editor
function seteditorcontents (editorname, contentstr) {
var oeditor = fckeditorapi.getinstance (editorname);
Oeditor.sethtml (CONTENTSTR);
}



Event handling for FCK
FCK defines events such as Oncomplete,onblur and onfocus, so that you can use the handler function of the event to do the processing appropriately.
FCK Add event Handlers by: fckInstance.Events.AttachEvent (EventName, function)
Code
Copy Code code as follows:

How to do the processing after the FCKeditor load completes
function Fckeditor_oncomplete (editorinstance)
{
EditorInstance.Events.AttachEvent (' OnBlur ', fckeditor_onblur);
EditorInstance.Events.AttachEvent (' onfocus ', fckeditor_onfocus);
}
function Fckeditor_onblur (editorinstance)
{
Lose focus and close the toolbar
EditorInstance.ToolbarSet.Collapse ();
}
function Fckeditor_onfocus (editorinstance)
{
EditorInstance.ToolbarSet.Expand ();
}

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.