从主机页面向对话框发送消息 [英] Send a message from host page to Dialog box
本文介绍了从主机页面向对话框发送消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用 Office加载项的对话框API .
根据文档,我们可以使用Office.context.ui.messageParent
将消息从对话框"发送到主机页面(例如,任务窗格).而我看不到如何从主机页面向对话框发送消息.
According to the doc, we could use Office.context.ui.messageParent
to send a message from the Dialog box to the host page (eg, task pane). Whereas, I don't see how we could send a message from the host page to the Dialog box.
有人知道该怎么做吗?
推荐答案
有2种可能的解决方案:
There are 2 possible solutions:
- 打开页面对话框时,将数据作为查询参数发送.
- 如果在同一域中,则应该在打开的对话框中使用本地存储.
setInterval(function () { var value = localStorage.getItem("dataFromDialog"); }, 500)
您可以在对话框localStorageSetItem("dataFromDialog", "message to parent")
中的localStorage中写入相同的值
- Send data as query params, when you open a pagein dialog box.
- If there are in same domain then localstorage should be available in dialog which was opened.
setInterval(function () { var value = localStorage.getItem("dataFromDialog"); }, 500)
You can write the same value in localStorage in dialoglocalStorageSetItem("dataFromDialog", "message to parent")
这篇关于从主机页面向对话框发送消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文