Javascript: HypertextLinkCollection.getItem Method
Description
Gets the hypertext link with the specified id.
Syntax
<void> HypertextLinkCollection.getItem(<RequestHypertextLinkCallback> callback, [<ErrorCallback> errorCallback], [<number> id])Parameters
| Parameter | Description |
|---|---|
| callback | Receives the hypertext link. |
| errorCallback | Optional. Is called when the operation failed with an error. |
| id | Optional. Specifies the document link's identifier set with the ID property. The method returns null if a link with the specified identifier does not exist. |
Examples
The following example demonstrates HypertextLinkCollection.getItem in a practical document-editing workflow. It gets the hypertext link with the specified id.
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(result) {
if (!result) {
console.warn("No hypertext link was returned.");
return;
}
console.log("get item result:", result);
},
onTxError,
25
);
}, onTxError);