Javascript: DocumentLink.setDocumentTarget Method
Description
Sets an object of the type DocumentTarget specifying to where the link points.
Syntax
<void> DocumentLink.setDocumentTarget(<DocumentTarget> documentTarget, [<EmptyRequestCallback> callback], [<ErrorCallback> errorCallback])Parameters
| Parameter | Description |
|---|---|
| documentTarget | Specifies to where the link points. |
| callback | Optional. Is called when the operation completed. |
| errorCallback | Optional. Is called when the operation failed with an error. |
Examples
The following example demonstrates DocumentLink.setDocumentTarget in a practical document-editing workflow. It sets 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;
}
function configureDocumentTarget(documentTarget) {
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.setDocumentTarget(
documentTarget,
function() {
console.log("set document target completed.");
},
onTxError
);
}, onTxError);
}, onTxError);
}