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.
Syntax
JavaScript
editliveInstance.setDocument(strDocument);
Parameters
strDocument
A string of the contents to be placed into the EditLive! applet.
Example
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.
<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="documentContents" cols="40" rows="10"> <html><body><p>Content to be loaded</p></body></html> </TEXTAREA> </P> <P>Click this button to set applet contents</P> <P> <INPUT type="button" name="button1" value="Set Contents" onClick="editlivejs.setDocument(encodeURI(document.exampleForm.documentContents.value));"> </P> <!--Create an instance of EditLive!--> <SCRIPT language="JavaScript"> var editlivejs; editlivejs = new EditLiveJava("editlive", 450, 275); editlivejs.setConfigurationFile("sample_config.xml"); editlivejs.show(); </SCRIPT> </FORM> </BODY> </HTML>
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.