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().

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

Last updated