The contents of the Ephox EditLive! for Java can be set at runtime using the EditLive! for Java JavaScript API. Consequently external JavaScript functions which exist, or are included, in the same page as the EditLive! for Java applet can access the contents of the applet. This allows for greater flexibility in the use of the EditLive! for Java applet.
The EditLive! for Java JavaScript API includes five functions which allow for the getting and setting of the applet contents at run time. These functions are as follows:
The GetStyles function retrieves the styling information from EditLive! for Java (i.e. that information which is stored in <STYLE> tags in the document <HEAD> tag). The other functions pertain to the getting and setting of the text within the applet. The GetBody and SetBody functions will, respectively, get and set all the content of the applet between the <BODY> tags. Whereas the GetDocument and SetDocument functions will, respectively, get and set all the content of the applet between the <HTML> tags (i.e. the entire document).
The SetBody or SetDocument functions can be used to set the contents of EditLive! for Java. These functions take a JavaScript string as their only parameter. The value of this parameter should be the URL encoded content to place inside EditLive! for Java. The JavaScript escape function can be used to encode the content. Through the use of the SetBody or SetDocument functions any existing content within EditLive! for Java will be replaced with the content specified via these functions.
This example demonstrates how to use the SetBody function for an EditLive! for Java applet denoted as the object editlivejava1. The content to be set is contained within the string bodyString.
editlivejava1.SetBody(escape(bodyString));
The GetBody or GetDocument functions can be used to get the contents of EditLive! for Java. These functions take a JavaScript functions as their only parameter. The value of this parameter should be the function which is to use the EditLive! for Java content.
This example demonstrates how to use the GetDocument function for an EditLive! for Java applet denoted as the object editlivejava1. The function to receive the applet contents is javaScriptFunction.
editlivejava1.GetDocument('javaScriptFunction');
Through the use of the GetStyles function style information can also be retrieved using the EditLive! for Java JavaScript API. The GetStyles function takes a JavaScript function as its only parameter. The value of this parameter should be the function which is to use the EditLive! for Java content.
This example demonstrates how to use the GetStyles function for an EditLive! for Java applet denoted as the object editlivejava1. The function to receive the applet contents is javaScriptFunction.
editlivejava1.GetStyles('javaScriptFunction');
Through the use of the EditLive! for Java JavaScript API the contents of EditLive! for Java can be get and set at run time. This gives developers greater flexibility when using EditLive! for Java.
Copyright © 2001-2004 Ephox Corporation. All Rights Reserved.