This function obtains a count of the number of characters present within the EditLive! applet. It counts the number of characters which are contained within controls on the current view.
Prior to version 8.1 this function had no return value and the function was asynchronous. While asynchronous use is still supported, since version 8.1 this function can now be used synchronously with a return value.
Syntax
JavaScript
int editliveInstance.getCharCount([jsFunct]);
Parameters
jsFunct
This parameter is optional.
The JavaScript function which receives the character count obtained from the EditLive! applet. This parameter can also be a string representation of the javascript function.
Returns
Number of characters in the document.
Note: this is the number of characters in the actual text of the document, not the number of characters in the HTML representation of the document.
Example Synchronous (EditLive 8.1+)
Calling getCharCount synchronously returns the the character count as a string. This example retrieves the character count and then displays it in a JavaScript alert dialog. The name of the EditLive applet is editlive_js.
var charCount = editlive_js.getCharCount();
Example Asynchronous (EditLive 8.0+)
When calling getCharCount asynchronously you must provide a JavaScript function as the callback parameter for the getCharCount method. In this example the charCountAlert callback function receives the character count as a string. The name of the EditLive applet is editlive_js.
editlive_js.getCharCount('charCountAlert');
The charCountAlert function receives the character count as a string and displays it in a JavaScript alert dialog.
function charCountAlert(count){ alert('Character Count: ' + count); }