# 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
});
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET 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?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
