InsertHyperlinkAtCursor Function

Description

This function applies a developer specified hyperlink to the text selected within EditLive! for Java.  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! for Java).  The first argument of this function must be the URL corresponding to the hyperlink, this argument is mandatory.  This function can also be used with an optional list of HTML attributes as arguments.  These arguments are then used as attributes for the hyperlink (<A>) tag and therefore must be valid HTML attribute-value pairs.

Syntax

JavaScript object.InsertHyperlinkAtCursor(strHyperlink, [strAttribute]*)

Parameters

strHTML Required.  The string containing the hyperlink to be inserted at the cursor within the EditLive! for Java applet. 
Note: This string should be URL encoded or escaped using the JavaScript escape function.
strAttribute Optional.  A valid HTML attribute-value pair for the <A> (hyperlink) HTML element.  Name value pairs must appear as they would within the HTML source (i.e. with correct use of quotation marks).
Note: This string should be URL encoded or escaped using the JavaScript escape function.  

Example

The following code creates a text <INPUT>, named hyperlinkToInsert, that will have its contents inserted into an instance of EditLive! for Java at the cursor position via the InsertHyperlinkAtCursor function.  The InsertHyperlinkAtCursor function will be associated with a HTML button.  The name of the EditLive! for Java applet is editlivejava1.

<HTML>
    <HEAD>
        <TITLE>EditLive! for Java JavaScript Example</TITLE>
        <!--Include the EditLive! for Java JavaScript Library-->
        <SCRIPT src="editlivejava/editlivejava.js" language="JavaScript"></SCRIPT>
    </HEAD>
    <BODY>
        <FORM name = exampleForm>
            <P>The selected hyperlink will be inserted into EditLive! for Java</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/editliveforjava/default.asp">EditLive! for Java
                <OPTION value="mailto:someone@yourserver.com">Email Link
            </SELECT>
            </P>
            <P>Click this button to insert hyperlink at the cursor in EditLive! for Java</P>
            <P>
            <INPUT type="button" name="button1" value="Insert Hyperlink" onClick="editlivejava1.InsertHyperlinkAtCursor(escape(document.exampleForm.hyperlinkToInsert.value));" >
            </P>
            <!--Create an instance of EditLive! for Java-->
            <SCRIPT language="JavaScript">
            <!--
                var editlivejava1;
                editlivejava1 = new EditLiveJava("eljava",450 , 275);
                editlivejava1.setDownloadDirectory("editlivejava");
                editlivejava1.setLocalDeployment(false);
                editlivejava1.setXMLURL("sample_eljconfig.xml");
                editlivejava1.setBody(escape("<p>Contents of EditLive! for Java</p>"));
                editlivejava1.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! for Java.  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.

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

Remarks

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

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

See Also