Sending post message to CODE

Make sure that your have added an eventListener to receive messages from the Wopi Client:

window.addEventListener("message", receiveMessage, false);

And than you should react on the first message ‘App_LoadingStatus’ and send a ‘Host_PostmessageReady’ message back to the client:

			if (msg.MessageId == 'App_LoadingStatus') {
				if (msg.Values) {
					if (msg.Values.Status == 'Document_Loaded') {
						console.log('==== Document loaded ...init viewer...');
						var iframe = document.getElementById('wopi-iframe');
			                        iframe = iframe.contentWindow || (iframe.contentDocument.document || iframe.contentDocument);									                   
                                                 iframe.postMessage(JSON.stringify({ 'MessageId': 'Host_PostmessageReady' }), '*');

					}
				}
				
			}

Find more details here.

1 Like