window.opener在Windows的Excel中不起作用 [英] window.opener does not work in Excel for Windows
问题描述
我已经构建了一个Excel加载项,它通过window.open
打开一个弹出窗口,然后该加载项与弹出站点进行通信.我只是意识到它在Windows的Excel中不起作用,原因是弹出窗口无法通过$window.opener
获取主机.
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
.
为了说明这一点并避免跨域,我已经制作了一个xml ,表示加载项和
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).
推荐答案
UI.messageParent
也无法正常工作吗?它来自官方文档.
UI.messageParent
also won't work? It's from the official docs.
示例:
Office.context.ui.messageParent("Message from Dialog box")
文档:
将消息从对话框传递到其父/打开页面.调用此API的页面必须与父页面位于同一域中.
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.
(我假设这不是您引用的Dialog API)
(I assume this isn't the Dialog API which you referring)
这篇关于window.opener在Windows的Excel中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!