EditLive! 9 Documentation : insertHTMLAtCursor Method

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





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


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.

      <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="htmlToInsert" cols="40" rows="10">
               <p>Content to be inserted</p>
         <P>Click this button to insert XHTML at the cursor in EditLive!</P>
            <INPUT type="button"
               value="Insert XHTML"
               onClick="editlivejs.insertHTMLAtCursor(encodeURI(document.exampleForm.htmlToInsert.value ));">
         <!--Create an instance of EditLive!-->
         <SCRIPT language="JavaScript"> 
            var editlivejs = new EditLiveJava("editlive", 450, 275);
            editlivejs.setDocument(encodeURIComponent("<P>This is EditLive!</P>"));

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