> For the complete documentation index, see [llms.txt](https://sway-technologies.gitbook.io/sway-charts-pro-scripts-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sway-technologies.gitbook.io/sway-charts-pro-scripts-documentation/sway-charts-pro-user-defined-indicators/adding-html-to-the-chart/7.4-sending-messages-from-the-udi-to-the-html.md).

# 7.4	Sending messages from the UDI to the HTML

Your UDI can send messages to its HTML. It is *much* more efficient to update the HTML by sending it a message, and having script in the HTML which changes the contents, rather than loading complete replacement HTML using a second call to UDI.createHTML().

&#x20;

The UDI sends a message to the HTML using UDI.sendHTMLMessage(). For example:

```
UDI.sendHTMLMessage("Some instruction to the HTML");
```

Script in the HTML listens for messages in the standard way, using a message listener on the window. For example:

```
window.addEventListener("message", function(event) {
	// The message from the UDI will be in event.data
});
```
