3

Below is integration code to include office iframe into application. But it does not send any message to parent iframe.

Application URL = https://FFC-word-edit.officeapps.live.com/we/wordeditorframe.aspx?wopisrc=WOPISRCURL&jsapi=1&sftc=1&wdenableroaming=1&mscc=1&wdodb=1&jsapiver=v1&&cac=1&mtf=1&sfp=1&wopicomplete=1&rct=Medium&ctp=LeastProtected&McasTsid=15600

<body>
    <form id="office_form" name="office_form" target="office_frame" action="${applicationURL}" method="post">
        <input name="access_token" id="access_token" value="${access_token}" type="hidden" />
        <input name="access_token_ttl" id="access_token_ttl" value="${access_token_ttl}" type="hidden" />
        <input name="host_install_addins" value="{ {addinId: 'WA104379642', type: 'TaskPaneApp'}} " type="hidden" />
    </form>
    <span id="frameholder"></span>

    <script type="text/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;

        alert('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);
    
    var frameholder = document.getElementById('frameholder');
    var office_frame = document.createElement('iframe');
    office_frame.name = 'office_frame';
    office_frame.id = 'office_frame';
    office_frame.title = 'Office Online Frame';
    office_frame.setAttribute('allowfullscreen', 'true');
    frameholder.appendChild(office_frame);
    document.getElementById('office_form').submit();
    sessionStorage.setItem('versionstatusrefreshes', 0);

    </script>
</body>

Does anyone has face such issue?

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45

0 Answers0