# Javascript: HypertextLink.setTarget Method

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

- **Product:** DS Server
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 28.0
- **Path:** DS Server > Reference > JavaScript API > Javascript: HypertextLink.setTarget Method
- **482 words**
- **Web URL:** https://docs.textcontrol.com/ds-server/reference/javascript/hypertextlink/settarget-method/
- **LLMs URL:** https://docs.textcontrol.com/ds-server/reference/javascript/hypertextlink/settarget-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/ds-server/reference/javascript/hypertextlink/settarget-method/llms-full.txt

---

### Description

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

### Syntax

```javascript
<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.

```javascript
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);
```

---

## Nearby

- **Previous:** [Javascript: HypertextLink.setDescriptiveText Method](https://docs.textcontrol.com/ds-server/reference/javascript/hypertextlink/setdescriptivetext-method/llms-full.txt)
- **Next:** [HypertextLinkClickedCallback Function](https://docs.textcontrol.com/ds-server/reference/javascript/hypertextlinkclickedcallback/llms-full.txt)
