EditLive! 9 Documentation : setDocument Method (Run Time)

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





A string of the contents to be placed into the EditLive! applet.


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

      <TITLE>EditLive! JavaScript Example</TITLE>
      <!--Include the EditLive! JavaScript Library-->
      <SCRIPT src="editlivejava/editlivejava.js" language="JavaScript">
      <FORM name = exampleForm>
         <P>EditLive! contents will be loaded from here</P>
         <!--Create a textarea to load the applet contents from-->
            <TEXTAREA name="documentContents" cols="40" rows="10">
               <html><body><p>Content to be loaded</p></body></html>
         <P>Click this button to set applet contents</P>
            <INPUT type="button"
               value="Set Contents"
         <!--Create an instance of EditLive!-->
         <SCRIPT language="JavaScript">
            var editlivejs;
            editlivejs = new EditLiveJava("editlive", 450, 275);

The string passed to the JavaScript setDocument 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