TX Text Control .NET Server

Javascript: HypertextLink.getTarget Method

Method|Introduced in 28.0

Description

Gets a string that specifies the target to where the hypertext link points.

Syntax

<void> HypertextLink.getTarget(<RequestHypertextLinkCallback> callback, [<ErrorCallback> errorCallback])

Parameters

ParameterDescription
callback

Receives a string that specifies the target to where the hypertext link points.

errorCallback

Optional. Is called when the operation failed with an error.

Examples

The following example demonstrates HypertextLink.getTarget in a practical document-editing workflow. It gets a string that specifies the target to where the hypertext link points.

function onTxError(error) {
    console.error("TX Text Control error:", error.msg);
    error.handled = true;
}

TXTextControl.textParts.getMainText(function(mainText) {
    const hypertextLinks = mainText.hypertextLinks;
    hypertextLinks.getItem(function(hypertextLink) {
        if (!hypertextLink) {
            console.warn("No hypertext link is available at the current input position.");
            return;
        }
    
        hypertextLink.getTarget(
            function(result) {
                if (!result) {
                    console.warn("No hypertext link was returned.");
                    return;
                }
                
                console.log("get target result:", result);
            },
            onTxError
        );
    }, onTxError);
}, onTxError);