Page tree
Skip to end of metadata
Go to start of metadata

This method inserts developer-specified HTML at the cursor within the EditLive! applet. This method takes a JavaScript string as its only parameter.

Syntax 

JavaScript
editliveInstance.insertHTMLAtCursor(strHTML);

Parameters

strHTML

The string containing the HTML to be inserted at the cursor within the EditLive! applet.

Example

The following code creates a <TEXTAREA>, named htmlToInsert, that will have its contents inserted into an instance of EditLive! at the cursor position via the InsertHTMLAtCursor method. The InsertHTMLAtCursor 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="htmlToInsert" cols="40" rows="10">
               <p>Content to be inserted</p>
            </TEXTAREA>
         </P>
         <P>Click this button to insert XHTML at the cursor in EditLive!</P>
         <P>
            <INPUT type="button"
               name="button1"
               value="Insert XHTML"
               onClick="editlivejs.insertHTMLAtCursor(encodeURI(document.exampleForm.htmlToInsert.value ));">
         </P>
         <!--Create an instance of EditLive!-->
         <SCRIPT language="JavaScript"> 
            var editlivejs = new EditLiveJava("editlive", 450, 275);
            editlivejs.setConfigurationFile("sample_elconfig.xml");
            editlivejs.setDocument(encodeURIComponent("<P>This is EditLive!</P>"));
            editlivejs.show();
         </SCRIPT>
      </FORM>
   </BODY>
</HTML> 

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

  • No labels