Javascript: HypertextLink.setTarget Method
Description
Sets a string that specifies the target to where the hypertext link points.
Syntax
<void> HypertextLink.setTarget(<string> value, [<EmptyRequestCallback> callback], [<ErrorCallback> errorCallback])Parameters
| Parameter | Description |
|---|---|
| value | A string that specifies the target to where the hypertext 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 HypertextLink.setTarget in a practical document-editing workflow. It sets 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.setTarget(
"https://www.example.com/invoices/2026",
function() {
console.log("set target completed.");
},
onTxError
);
}, onTxError);
}, onTxError);