EditLive! 9 Documentation : insertHyperlinkAtCursor Method

This method applies a developer-specified hyperlink to the text selected within EditLive!. If no text is selected, then the word in which the cursor is currently located will be selected and a hyperlink applied to it (this is the same functionality as the Insert Hyperlink button in EditLive!). The first argument of this method must be the URL corresponding to the hyperlink. This argument is mandatory. This method can also be used with an optional list of XHTML attributes as arguments. These arguments are then used as attributes for the hyperlink (<A>) tag and therefore must be valid XHTML attribute-value pairs.


editliveInstance.insertHyperlinkAtCursor(strHyperlink, [strAttribute]*);



This is a required parameter.

This string contains the hyperlink to be inserted at the cursor within the EditLive! applet.


This is an optional parameter.

A valid XHTML attribute-value pair for the <A> (hyperlink) XHTML element. Name-value pairs must appear as they would within the XHTML source (i.e. with correct use of quotation marks).


The following code creates a text <INPUT>, named hyperlinkToInsert, that will have its contents inserted into an instance of EditLive! at the cursor position via the insertHyperlinkAtCursor method. The insertHyperlinkAtCursor 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>The selected hyperlink will be inserted into EditLive!</P>
         <!--Create a text input to load the applet contents from-->
            <SELECT name="hyperlinkToInsert" size=3>
               <OPTION value="http://www.ephox.com" SELECTED> Ephox
               <OPTION value="http://www.ephox.com/product/editliveforxml/default.asp"> EditLive!
               <OPTION value="mailto:someone@yourserver.com">Email Link
         <P>Click here to insert hyperlink at the cursor in EditLive!</P>
            <INPUT type="button"
               value="Insert Hyperlink"
               onClick="editlivejs.insertHyperlinkAtCursor(document.exampleForm. hyperlinkToInsert.value);">
         <!--Create an instance of EditLive!-->
         <SCRIPT language="JavaScript">
            var editlivejs = new EditLiveJava("editlive",450 , 275);
            editlivejs.setBody(encodeURI("<p>Contents of EditLive! for Java</p>"));

The following example demonstrates how to use the insertHyperlinkAtCursor with multiple arguments used to specify the attributes of the hyperlink (<A> tag) to be inserted into EditLive!. This example demonstrates how the target (frame1) and name (hyperlink1) attributes can be specified for the hyperlink http://www.ephox.com. Note the use of double and single quotation marks in this example.

editlivejs.InsertHyperlinkAtCursor("http://www.ephox.com", "target='frame1'","name='hyperlink1'");


Note that this method can be used with differing numbers of arguments. However, the first argument of the method must always be the URL for the hyperlink and is not optional.

Arguments which represent XHTML attribute-value pairs must be valid XHTML. This includes the usage of the correct quotations marks.

See Also