Javascript: DocumentLink.getDocumentTarget Method
Description
Gets an object of the type DocumentTarget specifying to where the link points.
Syntax
<void> DocumentLink.getDocumentTarget(<RequestDocumentTargetCallback> callback, [<ErrorCallback> errorCallback])Parameters
| Parameter | Description |
|---|---|
| callback | Receives the link's target. |
| errorCallback | Optional. Is called when the operation failed with an error. |
Examples
The following example demonstrates DocumentLink.getDocumentTarget in a practical document-editing workflow. It gets an object of the type DocumentTarget specifying to where the link points.
function onTxError(error) {
console.error("TX Text Control error:", error.msg);
error.handled = true;
}
TXTextControl.textParts.getMainText(function(mainText) {
const documentLinks = mainText.documentLinks;
documentLinks.getItem(function(documentLink) {
if (!documentLink) {
console.warn("No document link is available at the current input position.");
return;
}
documentLink.getDocumentTarget(
function(result) {
if (!result) {
console.warn("No document target was returned.");
return;
}
console.log("get document target result:", result);
},
onTxError
);
}, onTxError);
}, onTxError);