Cross-domain messaging not working as expected in Office dialog API

Ravi Varma Bathula 0 Reputation points
2025-03-18T09:44:56.7266667+00:00

We are using OfficeDialogAPI to open dialog boxes in our Office Add-in. While closing the Dialog Box, we need to send some data to the parent host and we are using Office.context.ui.messageParent & Office.EventType.DialogMessageReceived to handle the messages that come from the Dialog as shown below:

Office.context.ui.messageParent('message', { targetOrigin: '*' })

dialog.addEventHandler(Office.EventType.DialogMessageReceived, (arg) => {
          console.log('Message from dialog:', arg.message);
          dialog.close();
        });

Since the domain is different in the parent host and in the Dialog Box, we are also setting **targetOrigin: *** so that our message is considered by Parent. (As per MS documentation provided here). But unfortunately this is working as expected and we are currently blocked on this issue.

This is not working on all three platforms we are testing - Mac, Windows & Web.

Can someone please help us here?

JavaScript API
JavaScript API
An Office service that supports add-ins to interact with objects in Office client applications.
1,058 questions
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.