# Javascript: Selection.load Method

> Loads text in a certain format into the current selection.

- **Product:** DS Server
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 24.0
- **Path:** DS Server > Reference > JavaScript API > Javascript: Selection.load Method
- **442 words**
- **Web URL:** https://docs.textcontrol.com/ds-server/reference/javascript/selection/load-method/
- **LLMs URL:** https://docs.textcontrol.com/ds-server/reference/javascript/selection/load-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/ds-server/reference/javascript/selection/load-method/llms-full.txt

---

### Description

Loads text in a certain format into the current selection.

### Syntax

```javascript
<void> Selection.load(<StreamType> streamType, <string> base64Data, [<EmptyRequestCallback> callback], [<LoadSettings> loadSettings], [<ErrorCallback> errorCallback])
```

### Parameters

| Parameter | Description |
|---|---|
| streamType | Document format. |
| base64Data | Base64 encoded document data. |
| callback | Optional. Is called when the operation completed. |
| loadSettings | Optional. Additional settings for loading the data. |
| errorCallback | Optional. Is called when the operation failed with an error. |

### Examples

The following example demonstrates `Selection.load` in a practical document-editing workflow. It loads text in a certain format into the current selection.

```javascript
function onTxError(error) {
    console.error("TX Text Control error:", error.msg);
    error.handled = true;
}

TXTextControl.selection.load(
    TXTextControl.StreamType.HTMLFormat,
    "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAFgAH/qbPzWQAAAABJRU5ErkJggg==",
    function() {
        console.log("load completed.");
    },
    { loadImages: true, loadHypertextLinks: true },
    onTxError
);
```

---

## Nearby

- **Previous:** [Javascript: Selection.listFormat Property](https://docs.textcontrol.com/ds-server/reference/javascript/selection/listformat-property/llms-full.txt)
- **Next:** [Javascript: Selection.paragraphFormat Property](https://docs.textcontrol.com/ds-server/reference/javascript/selection/paragraphformat-property/llms-full.txt)
