Global API of FCKeditor

Source: Internet
Author: User
FCKeditor offers a complete javascript API, fckediAuthor: P. Dragon Date: font size: medium and large

FCKeditor offers a complete javascript API so you can interact with it once the editor is loaded and running.

Retrieving
An editor instanceonce loaded, the editor registers a Global Object
Called fckeditorapi. This object offers the entry point to interact
With any editor instance placed in a page (you can have more than one ).
When placing the editor in the page, you give it an "Instance name ".
So, to retrieve it, you must simply call the fckeditorapi. getinstance
Method. For example:

VaR oeditor = fckeditorapi. getinstance ('instancename ');

The returned object
The
Getinstance method returns the main FCKeditor object that gives
Necessary bridge to interact with it. This is a list of properties and
Methods of this object:

* Description = string
* Editmode = integer
* Name = string
* Status = integer
* Function attachtoonselectionchange (functionpointer)
* Function cleanandpaste (HTML)
* Function createelement (TAG)
* Function CreateLink (URL)
* Function execonselectionchange () // fires onselectionchange event in event manager
* Function execonselectionchangetimer ()
* Function executenamedcommand (commandname, commandparameter)
* Function executeredirectednamedcommand (commandname, commandparameter)
* Function focus ()
* Function gethtml (Format) // doesnt work. Use getxhtml instead.
* Function getnamedcommandstate (commandname)
* Function getnamedcommandvalue (commandname)
* Function getxhtml (Format)
* Function initializebehaviors ()
* Function insertelement (element)
* Function insertelementandgetit (E)
* Function inserthtml (HTML)
* Function isdirty ();
* Function makeeditable ()
* Function ondoubleclick (element)
* Function paste ()
* Function pasteasplaintext ()
* Function pastefromword ()
* Function Preview ()
* Function registerdoubleclickhandler (handlerfunction, tag)
* Function resetisdirty ();
* Function sethtml (HTML, forcewysiwyg)
* Function setstatus ()
* Function showcontextmenu (x, y)
* Function switcheditmode ()
* Function updatelinkedfield ()

Eventsonce
The editor loading is complete and it is ready to use (and interact
With JavaScript), a standard function is called in the page that
Contains the editor, if the function is defined. This function must be
Named "fckeditor_oncomplete" and parameters es the related editor instance
As the parameter. Using It, You can execute any initial code that makes
The initial interaction with the editor. This is a declaration example:

Function fckeditor_oncomplete (editorinstance)
{
Alert (editorinstance. Name );
}

Apart
The above standard event, every FCKeditor instance has a "Event" Object
That can be used to listen for events to be fired. For example,
Following code listens for the "onselectionchange" to execute custom
Code:

VaR counter = 0;
Function dosomething (editorinstance)
{
Required parameter Doc ument. Title = editorinstance. Name + ':' + (++ counter );
}
Function fckeditor_oncomplete (editorinstance)
{
Editorinstance. Events. attachevent ('onselectionchang', dosomething );
}

Note that every callback function has es the editor instance as a parameter.

The following is the list of events available:

Onselectionchange:
Fired when the actual selection in the editor area changes (
Selection I mean the cursor position too... it changes on key strokes ).
Note: in IE6, this event does not fire on every keystroke, but only on
Some random keystrokes. Handy!

Onaftersethtml: fired once the HTML is loaded in the editor (including when changing views ).

Onstatuschange:
Fired when the editor status changes. The following constants are also
Available globally in the page: fck_status_notloaded, fck_status_active
And fck_status_complete.

Onpaste: fired when something is pasted in the editor

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.