EditLive! 9 Documentation : Getting the Body in the Applet Code
Created by Jessica Hardy, last modified by Kristin Repsher on May 22, 2012
<!--
******************************************************
getBody.html --
This tutorial shows developers how to extract the contents
of the <BODY> attribute for the HTML Document stored in
EditLive! and store this HTML in a webpage field.
Copyright © 2001-2006 Ephox Corporation. All rights reserved.
See license.txt for license agreement
******************************************************
-->
<html>
<head>
<title>Tutorial - Getting the Body of the Editor's HTML Document</title>
<link rel="stylesheet" href="stylesheet.css">
<!--
Include the EditLive! JavaScript Library
-->
<script src="../../redistributables/editlivejava/editlivejava.js" language="JavaScript"></script>
</head>
<body>
<h1>Getting the Body of the Editor's HTML Document</h1>
<form name="exampleForm">
<p>This tutorial shows how to extract the contents of the <BODY> attribute of the HTML Document in EditLive! and display this HTML in a textarea on the webpage.</p>
<!--
The textarea used to display the HTML from the <body> of EditLive!'s HTML document.
-->
<textarea id="bodyContents" cols="80" rows="5">Pressing the Get <BODY> Contents button will extract the <BODY> from EditLive! and place the HTML into this textarea.</textarea>
<!--
The button for copying the <BODY> content from EditLive! and displaying this HTML in the textarea
-->
<p><input type="button" value="Get <BODY> 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.setBody(encodeURIComponent("<p>Original <i>HTML</i> loaded into EditLive!</p>"));
// .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 <body> field of the EditLive! HTML Document
* and displays this content in the textarea
*/
function buttonPress() {
// the parameter passed to the GetBody method is the callback method the applet will call, passing
// the contents of the <BODY> attribute.
editlive.getBody('getEditLiveBody');
}
function getEditLiveBody(src) {
document.exampleForm.bodyContents.value = src;
}
</script>
</form>
</body>
</html>