我想自动加载我的外接程序到在线办公365字.
根据文档,我创建了一个带有POST表单的主页,它从发现请求中调用url。我包括了?sftc=1参数,以启用supportsFrameTrustedPostMessage。
<form id="office_form" name="office_form" target="office_frame" action="https://FFC-word-edit.officeapps.live.com/we/wordeditorframe.aspx?sftc=1&WOPISrc=https://fileUrl" method="post">
<input name="access_token" value="xxxx" type="hidden"/>
<input name="access_token_ttl" value="yyyy" type="hidden"/>
<input name="host_install_addins" value='[{"addinId": "WA104380121", "type": "TaskPaneApp"}]' type="hidden"/>页面加载后,办公应用程序应该发送App_IsFrameTrusted,postMessage,这是一个握手初始化。来自主页的答复应该是Host_IsFrameTrusted.
问题是,那个办公室没有发送这个App_IsFrameTrusted的帖子信息。
下面是由主页接收的post消息列表:

有人有这方面的经验吗?非常感谢。
发布于 2022-01-14 12:56:40
你也能把你的javascript发出去吗?应该是这样的:
function handlePostMessage(e) {
// The actual message is contained in the data property of the event.
var msg = JSON.parse(e.data);
// The message ID is now a property of the message object.
var msgId = msg.MessageId;
console.log('Received PostMessage ' + msgId + ' from ' + e.origin);
if (msgId === 'App_IsFrameTrusted') {
// Post back Host_IsFrameTrusted
var msg = {
"MessageId": "Host_IsFrameTrusted",
"SendTime": Date.now(),
"Values": {
"isTopFrameTrusted": true // Hack
}
};
// Check e.origin is expected origin
e.source.postMessage(msg, e.origin);
}
}
window.addEventListener('message', handlePostMessage, false);https://stackoverflow.com/questions/70697023
复制相似问题