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

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.

Syntax 

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

Parameters

strHyperlink

This is a required parameter.

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

strAttribute

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).

Example

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.

<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>The selected hyperlink will be inserted into EditLive!</P>
         <!--Create a text input to load the applet contents from-->
         <P>
            <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
            </SELECT>
         </P>
         <P>Click here to insert hyperlink at the cursor in EditLive!</P>
         <P>
            <INPUT type="button"
               name="button1"
               value="Insert Hyperlink"
               onClick="editlivejs.insertHyperlinkAtCursor(document.exampleForm. hyperlinkToInsert.value);">
         </P>
         <!--Create an instance of EditLive!-->
         <SCRIPT language="JavaScript">
            var editlivejs = new EditLiveJava("editlive",450 , 275);
            editlivejs.setConfigurationFile("sample_config.xml");
            editlivejs.setBody(encodeURI("<p>Contents of EditLive! for Java</p>"));
            editlivejs.show();
         </SCRIPT>
      </FORM>
   </BODY>
</HTML> 

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'");

Remarks

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

  • No labels