EditLive! 9 Documentation : getWordCount Method

This method obtains a count of the number of words present within the EditLive! applet. It counts the number of words which lie between the <BODY> tags.

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
String editliveInstance.getWordCount([jsFunct]);

Parameters

jsFunct

This parameter is optional.

The JavaScript function which receives the word count obtained from the EditLive! applet.

Returns

The word count.

Example Synchronous (EditLive 8.1+)

Calling getWordCount synchronously returns the the word count as a string. This example retrieves the word count and then displays it in a JavaScript alert dialog. The name of the EditLive applet is editlive_js.

var wordCount = editlive_js.getWordCount();

Example Asynchronous (EditLive 8.0+)

When calling getWordCount asynchronously you must provide a JavaScript function as the callback parameter for the getWordCount method. In this example the wordCountAlert callback function receives the word count as a string. The name of the EditLive applet is editlive_js.

editlive_js.getWordCount('wordCountAlert');

The wordCountAlert function receives the word count as a string and displays it in a JavaScript alert dialog.

function wordCountAlert(count){
        alert('Word Count: ' + count);
    }