EditLive! 9 Documentation : getStyles Method

This method retrieves the styling information from the EditLive! applet. It will retrieve all style information which lies between the <STYLE> tags in the document's <HEAD>.

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.getStyles([strJSFunct]);

Parameters

jsFunct

This parameter is optional.

The JavaScript function which receives the retrieved EditLive! style information.

Returns

The EditLive! style information.

Example Synchronous (EditLive 8.1+)

Calling getStyles synchronously returns the style information from the editor as a string. This example retrieves the style information and then saves the style information to a <textarea> with the name styleInfo. The name of the EditLive applet is editlive_js.

document.exampleForm.styleInfo.value = editlive_js.getStyles();

Example Asynchronous (EditLive 8.0+)

When calling getStyles asynchronously you must provide a JavaScript function as the callback parameter for the getStyles method. In this example the retrieveStyles callback function receives the style information from the editor as a string. The name of the EditLive applet is editlive_js.

editlive_js.getStyles('retrieveStyles');

The retrieveStyles function receives the style information from the editor and then saves the retrieved styles to a <textarea> with the name styleInfo.

function retrieveStyles(styles){
        document.exampleForm.styleInfo.value = styles;
    }

See Also