window.opener does not work in Excel for Windows

2019-07-10 02:35发布

I have built an Excel add-in, it opens a popup by window.open, then the add-in communicates with the popup site. I just realised that it does NOT work in Excel for Windows, the reason is that the popup can NOT get the host by $window.opener.

To illustrate this and avoid cross-domain, I have made a xml, which refers to the add-in and the test page. It works well in Excel Online in Chrome and in IE. However, while running it in Excel for Windows, $window.opener returns undefined.

Could anyone tell me what happened, and what's the workaround?

(for people who recommend Dialog API, please see this thread. So now neither Dialog nor window.open works in Excel for Windows).

1条回答
女痞
2楼-- · 2019-07-10 03:08

UI.messageParent also won't work? It's from the official docs.

Example:

Office.context.ui.messageParent("Message from Dialog box")

Docs:

Delivers a message from the dialog box to its parent/opener page. The page calling this API must be on the same domain as the parent.

(I assume this isn't the Dialog API which you referring)

查看更多
登录 后发表回答