UltimateEditor Client-Side API

API Element Description Example
UltimateEditors[ultimateEditorId] UltimateEditor object collection. UltimateEditors['UltimateEditor1']
UltimateEditors['<%=UltimateEditor1.ClientID%>']
UltimateEditors.UltimateEditor1
UltimateEditors.<%=UltimateEditor1.ClientID%>
[ultimateEditorId]_OnLoad() Function template to handle window onload events after the UltimateEditor control is completely loaded and ready to be reached by the UltimateEditors collection on the client-side. function UltimateEditor1_OnLoad() {/* custom function */}
function <%=UltimateEditor1.ClientID%>_OnLoad() {/* custom function */}
GetCurrentRange() Gets the current range in the editor (refer to Internet Explorer and Mozilla documentation). UltimateEditors['UltimateEditor1'].GetCurrentRange();
StoreCurrentRange() Stores the current range in the editor so that the same range can be selected before using functions such as InsertText, InsertHTML and SetFocus. Otherwise, the current range will be lost once the editor loses the focus. UltimateEditors['UltimateEditor1'].StoreCurrentRange();
InsertText(textStr) Inserts text fragment into the editor. Note that you should call StoreCurrentRange() before this function if you want to insert text into the current position. UltimateEditors['UltimateEditor1'].InsertText('Hello world!');
InsertHTML(htmlStr) Inserts HTML fragment into the editor. Note that you should call StoreCurrentRange() before this function if you want to insert HTML into the current position. UltimateEditors['UltimateEditor1'].InsertHTML('<b>Hello world!</b>');
GetEditorHTML() Gets the HTML of the editor. var strHTML = UltimateEditors['UltimateEditor1'].GetEditorHTML();
SetEditorHTML(htmlStr) Sets the HTML of the editor. UltimateEditors['UltimateEditor1'].SetEditorHTML('<b>Hello world!</b>');
GetEditorText() Gets the text of the editor. var strText = UltimateEditors['UltimateEditor1'].GetEditorText();
GetCharacterCount() Gets the number of characters typed in the editor. var wordCount = UltimateEditors['UltimateEditor1'].GetCharacterCount();
GetHtmlCount() Gets the length of HTML of the editor. var htmlCount = UltimateEditors['UltimateEditor1'].GetHtmlCount();
GetWordCount() Gets the number of words typed in the editor. var wordCount = UltimateEditors['UltimateEditor1'].GetWordCount();
SetFocus() Sets focus into the editor. Note that you should call StoreCurrentRange() before this function if you want to set focus to the current position. UltimateEditors['UltimateEditor1'].SetFocus();
AddEventHandler(eventName,functionNotify) Binds the specified function to an event so that the function gets called whenever the event fires on the editor.

eventName: String that specifies any of the standard DHTML events. functionNotify: Pointer that specifies the function to call when eventName fires.

Note that eventName should not have 'on' as prefix. For example, if you want to add an event handler for onload, you should pass 'load' instead of 'onload'.
UltimateEditors['UltimateEditor1'].AddEventHandler('blur', HandleBlur);

function HandleBlur() {
  alert('Blur event fired.');
}
RemoveEventHandler(eventName,functionNotify) Unbinds the specified function from the event, so that the function stops receiving notifications when the event fires.

eventName: String that specifies any of the standard DHTML events. functionNotify: Pointer that specifies the function to call when eventName fires.

Note that eventName should not have 'on' as prefix. For example, if you want to add an event handler for onload, you should pass 'load' instead of 'onload'.
UltimateEditors['UltimateEditor1'].RemoveEventHandler('blur', HandleBlur);
GetEventKeyCode(event) Retrieves the Unicode key code associated with the key that caused the event.

event: Event object that represents the state of an event.
UltimateEditors['UltimateEditor1'].GetEventKeyCode(event);
CancelEvent(event) Cancels the event if it is cancelable so that any default action normally taken by the implementation as a result of the event will not occur.

event: Event object that represents the state of an event.
UltimateEditors['UltimateEditor1'].CancelEvent(event);
CancelCommand() Cancels the command to execute when a toolbar button is clicked or toolbar dropdown selection is changed.

Note that CancelCommand() can only be called inside OnBeforeClickHandler or OnBeforeChangeHandler event handlers.
UltimateEditors['UltimateEditor1'].CancelCommand();
ExecuteCommand(commandToExec, userInterface, commandVal) Executes a command on the current selection.

commandToExec: Required. String that specifies the command to execute. This command can be any of the command identifiers (refer to Internet Explorer and Mozilla documentation) that can be executed in script.
userInterface: Optional. Boolean that specifies whether a user interface is displayed.
commandVal: Optional. Variant that specifies the string, number, or other value to assign. Possible values depend on commandToExec.
UltimateEditors['UltimateEditor1'].ExecuteCommand('ForeColor', false, '#FF0000');
SetEditorHtmlBeforePostBack() Sets editor content before the page is programmatically submitted by __doPostBack method. UltimateEditors['UltimateEditor1'].SetEditorHtmlBeforePostBack();