EditLive! 9 Documentation : setBody Method (Run Time)

This method sets the contents of the EditLive! applet between the <BODY> tags. It will replace any existing contents of the applet with the contents the function is provided with as its parameter. This method takes a JavaScript string as its only parameter. 

Syntax

JavaScript
editliveInstance.setBody(strBody);

Parameters

strBody

The string representing the contents to be placed into the EditLive! applet between the <BODY> tags.

Examples

The following code creates a <TEXTAREA>, named bodyContents, that will have its contents loaded into an instance of EditLive! via the setBody method. The setBody method will be associated with a HTML button. The name of the EditLive! applet is editlive_js.

<HTML>
   <HEAD>
      <TITLE>EditLive! JavaScript Example</TITLE>
      <!--Include the EditLive! JavaScript Library-->
      <SCRIPT src="editlivejava/editlivejava.js" language="JavaScript">
      </SCRIPT>
   </HEAD>
   <BODY>
      <FORM name = exampleForm>
         <P>EditLive! 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="editlive_js.setBody(encodeURI(document.exampleForm.bodyContents.value));">
         </P>
         <!--Create an instance of EditLive!-->
         <SCRIPT language="JavaScript">
            var editlive_js = new EditLiveJava("editlive", 450, 275);
            editlive_js.setConfigurationFile("sample_elconfig.xml");
            editlive_js.show();
         </SCRIPT>
      </FORM>
   </BODY>
</HTML>

The string passed to the JavaScript setBody method must be URL encoded. It is recommended that a server-side URL encoding function be used if available as the JavaScript encodeURI function does not fully comply with the URL encoding standard.

See Also