This example demonstrates how to load the contents of the EditLive! for Java applet at run time using the EditLive! for Java JavaScript API.
This example requires a JavaScript capable browser and a Web server.
The following skills are required prior to working with this sample:
This example consists of a single Web page which contains an instance of EditLive! for Java and a text area. Valid HTML content can be placed in the text area and then loaded into EditLive! for Java between the <BODY> tags through the click of a button. In order to achieve this functionality the example uses the run time functions of the EditLive! for Java JavaScript API.
This sample demonstrates how to perform the following with EditLive! for Java and JavaScript:
<form name="exampleForm">
<!--Include the EditLive! for Java JavaScript API -->
<script language="JavaScript" src="../../../../editlivejava/editlivejava.js"></script>
<!--Create a textarea to load the applet contents from-->
<P>
<TEXTAREA name="bodyContents" cols="40" rows="10"><p>Content to be loaded</p></TEXTAREA>
</P>
Note: The content to be placed into EditLive! for Java will be placed
between the <BODY> tags and must be valid HTML.<INPUT type="button" name="button1" value="Set Contents"
onClick="editlivejava1.SetBody(escape(document.exampleForm.bodyContents.value));" >
<!--Create an instance of EditLive! for Java-->
<SCRIPT language="JavaScript">
<!--
var editlivejava1;
editlivejava1 = new EditLiveJava("eljava",450 , 275);
editlivejava1.setDownloadDirectory("../../../../editlivejava");
editlivejava1.setLocalDeployment(false);
editlivejava1.setXMLURL("../sample_eljconfig.xml");
editlivejava1.show();
-->
</SCRIPT>
The following is the completed code as it would appear if the above steps were followed.
<HTML>
<HEAD>
<TITLE>EditLive! for Java JavaScript Example</TITLE>
<!--Include the EditLive! for Java JavaScript Library-->
<SCRIPT src="../../../../editlivejava/editlivejava.js" language="JavaScript"></SCRIPT>
</HEAD>
<BODY>
<FORM name = exampleForm>
<P>EditLive! for Java contents will be loaded from here</P>
<!--Create a textarea to load the applet contents from-->
<P>
<TEXTAREA name="bodyContents" cols="40" rows="10"><p>Content to be loaded</p></TEXTAREA>
</P>
<P>Click this button to set applet contents</P>
<P>
<INPUT type="button" name="button1" value="Set Contents"
onClick="editlivejava1.SetBody(escape(document.exampleForm.bodyContents.value));" >
</P>
<!--Create an instance of EditLive! for Java-->
<SCRIPT language="JavaScript">
<!--
var editlivejava1;
editlivejava1 = new EditLiveJava("eljava",450 , 275);
editlivejava1.setDownloadDirectory("../../../../editlivejava");
editlivejava1.setLocalDeployment(false);
editlivejava1.setXMLURL("../sample_eljconfig.xml");
editlivejava1.show();
-->
</SCRIPT>
</FORM>
</BODY>
</HTML>
Through the use of the EditLive! for Java JavaScript API EditLive! for Java can be instantiated within a Web page. The contents of EditLive! for Java can then loaded at run time through the use of the run time functions present in this API. This example has demonstrated how to perform these operations using the aforementioned API in order to enable the loading of content into EditLive! for Java from a text area.
Copyright © 2001-2004 Ephox Corporation. All Rights Reserved.