EditLive! 9 Documentation : getBody Method

This function retrieves the contents of the EditLive! applet. It will retrieve all contents 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.getBody([jsFunct], [blnUploadImages]);

Parameters

jsFunct

This parameter is optional.

The javascript function which receives the EditLive! applet contents.

blnUploadImages

This parameter is optional.

This is a boolean which indicates whether images should be uploaded to the server when this method is called. The uploading of images will occur immediately before the content is retrieved.

The default value is false.

Returns

The EditLive applet contents.

Synchronous Example (EditLive 8.1+)

Calling getBody synchronously returns the <body> contents of the editor as a string. This example retrieves the contents of the editor and then saves the retrieved contents to a <textarea> with the name bodyContent. Images will be uploaded to the server when getBody is called as blnUploadImages is set to true. The name of the EditLive applet is editlive_js.

document.exampleForm.bodyContent.value = editlive_js.getBody(true);

Asynchronous Example (EditLive 8.0+)

When calling getBody asynchronously you must provide a JavaScript function as the callback parameter for the getBody method. In this example the retrieveBody callback function receives the contents of the editor as a string. Images will be uploaded to the server when getBody is called as blnUploadImages is set to true. The name of the EditLive applet is editlive_js.

editlive_js.getBody("retrieveBody", true);

The retrieveBody function receives the contents of the editor and then saves the retrieved contents to a <textarea> with the name bodyContents.

function retrieveBody(src){
        document.exampleForm.bodyContent.value = src;
     }

Remarks

When uploading locally stored images to the relevant Web server for an instance of EditLive!, ensure that the blnUploadImages parameter is set to true when calling the getBody method.

See Also