EditLive! 9 Documentation : Setting the Document in the Applet Code

<!--
******************************************************
 
 setDocument.html --
 
 This tutorial shows developers how to populate the HTML
 Document stored in EditLive!, at both load-time and run-time.
 
 Copyright © 2001-2006 Ephox Corporation. All rights reserved.
 See license.txt for license agreement
 
******************************************************
-->
<html>
       <head>
               <title>Setting the Editor's HTML Document - Tutorial</title>
               <link rel="stylesheet" href="stylesheet.css">
               <!--
               Include the EditLive! JavaScript Library
               -->
               <script src="../../redistributables/editlivejava/editlivejava.js" language="JavaScript"></script>
       </head>
       <body>
 
               <h1>Setting the Editor's HTML Document</h1>
 
               <form name="exampleForm">
 
                       <p>This tutorial shows how to populate the HTML Document stored in EditLive!</p>
 
                       <p>This tutorial also shows how to extract the contents of a webpage field and store it's contents in EditLive! HTML Document </p>
 
                       <!--
                               The textarea used to load HTML content into EditLive!'s HTML document.
                       -->
                       <textarea id="documentContents" cols="80" rows="5"><html><head><title>New Document Title</title></head><body><p>A New HTML Document to load into <b>EditLive!</b></p></body></html></textarea>
 
                       <!--
                       The button for copying the content from the textarea to EditLive!
                       -->
                       <p>Pressing this button will copy the HTML contents of the above textarea into the &lt;BODY&gt; of the Document stored in EditLive!<br/>
                       <input type="button" value="Set HTML Contents" onclick="buttonPress()"></p>
 
                       <!--
                       The instance of EditLive!
                       -->
                       <script language="JavaScript">
                               // Create a new EditLive! instance with the name "ELApplet", a height of 400 pixels and a width of 700 pixels.
                               var editlive = new EditLiveJava("ELApplet", 700, 400);
 
                               // This sets a relative or absolute path to the XML configuration file to use
                               editlive.setConfigurationFile("../../redistributables/editlivejava/sample_eljconfig.xml");
 
                               // Before sending HTML to the instance of EditLive!, this HTML must be URL Encoded.
                               // Javascript provides several URL Encoding methods, the best of which is
                               // 'encodeURIComponent()'
                               editlive.setDocument(encodeURIComponent("<html><head><title>Default Document Title</title></head><body><p>Original <i>HTML Document</i> loaded into EditLive!</p></body></html>"));
 
                               // .show is the final call and instructs the JavaScript library (editlivejava.js) to insert a new EditLive! instance
                               //  at the this location.
                               editlive.show();
 
                               /** Function extracts the contents of the 'bodyContents' textarea and sets this HTML into
                                * the <body> field of the EditLive! HTML Document.
                                */
                               function buttonPress() {
                                       // Before sending HTML to the instance of EditLive!, this HTML must be URL Encoded.
                                       // Javascript provides several URL Encoding methods, the best of which is
                                       // 'encodeURIComponent()'
                                       editlive.setDocument(encodeURIComponent(document.exampleForm.documentContents.value));
                               }
                       </script>
 
               </form>
       </body>
</html>