The ISM Webapp Iframe Communication API (version 1.0.0) enables secure cross-origin communication between an embedded ISM (Interactive Space Manager) web application and its parent page using the Window.postMessage() mechanism. This JavaScript library facilitates interaction with the ISM webapp.
The API is provided as a JavaScript library that you include in your code. It requires an iframe to host the ISM webapp and initializes a communication channel between the parent page and the embedded application.
Include the minified JavaScript library in your HTML:
<script type="text/javascript" src="https://apps.zondavirtual.com/api/webappISM-1.0.min.js"></script>A demonstration of the API is available at: https://apps.zondavirtual.com/demo/webapp_communication/ism/index.html
To use the API, initialize it by creating an instance of ZONDA.WebappISMApi with a reference to the iframe hosting the ISM webapp and a callback function to handle initialization results.
The ISM webapp must be loaded in an iframe. Set the iframe's src attribute to the ISM application URL, which typically includes a plan ID. For example:
<iframe id="ismIframe" style="height:100%;width:100%" src="https://apps.zondavirtual.com/alphamap/index.html?OLAId=2542609e-fa60-40d1-b191-b3b7364c88f3&noheader" onload="iframeLoaded(event)"></iframe>The API requires time to initialize as it waits for the ISM webapp to load. During this period, you can display a placeholder image or a gray background (as shown in the demo) to improve the user experience. Once initialization is complete, the specified callback function is invoked with a success or error message.

You can confirm that the connection has been successfully established by observing the following messages in the browser console:
Parameters marked with an asterisk () are mandatory.
var webappISM;
var iframeLoaded = (e) => {
webappISM = new ZONDA.WebappISMApi(document.getElementById("ismIframe"), (result) => {
if (result.success) {
console.log(result.message); // e.g., "api loaded in 1.833 sec"
} else {
console.log(result.message); // e.g., "error message"
}
});
};
The following instance variables are available on a WebappISMApi object after initialization:
'ISM'.Currently, the WebappISMApi does not define any additional instance methods beyond the loaded call back information. Future updates may add ISM-specific functionality.
The API returns the following message IDs in responses:
The following error may appear in the console if initialization fails:

The following considerations are critical for secure usage of the API
Window.postMessage()event are managed in each.Common issues and their solutions: