PostMessage

PostMessage is the HTML5 Web Messaging protocol which allows exchanging messages in the browser between the iframe storage and ONLYOFFICE Docs. It allows the online office frame to communicate with its parent host page.

otherWindow.postMessage (msg, targetOrigin)
Parameters
Name Description Type
The message data:
  • MessageId - the message name,
    type: string,
    example: "App_LoadingStatus";
  • SendTime - the time the message was sent, expressed as milliseconds since midnight 1 January 1970 UTC,
    type: integer,
    example: 1329014075000;
  • Values - the message properties,
    type: JSON object.
string or JSON object
The otherWindow origin that must be for the event to be dispatched. It will be set to the PostMessageOrigin property provided in CheckFileInfo.
*otherWindow is a reference to another window that msg will be posted to.
string

Here you can find the messages that are available for ONLYOFFICE Docs to send to the host page. The process of receiving messages by the online office will be available later.

Available messages
MessageId Description
This message is posted after the online office application frame was loaded. Until the host receives this message, it must assume that the online office frame cannot react to any incoming messages except Host_PostmessageReady.
This message is posted when the user first makes an edit to a document, and every five minutes thereafter, if the user has made edits over the last five minutes. Hosts can use this message to gauge whether users are interacting with the online office. In co-authoring sessions, hosts cannot use the WOPI calls for this purpose.
This message is posted when the user renames the current file in the online office. The host can use this message to optionally update the UI, such as the page title.
This message is posted when the online office application is closing, either due to an error or a user action. To send this message, the ClosePostMessage property in the CheckFileInfo response from the host must be set to true. Otherwise, the online office will not send this message.
This message is posted when the user activates the Edit UI in the online office. This UI is only visible when using the view action. To send this message, the EditModePostMessage property in the CheckFileInfo response from the host must be set to true. Otherwise, the online office will not send this message and will redirect the inner iframe to the edit action URL instead.
This message is posted when the user activates the Previous Versions UI in the online office. The host should use this message to trigger any custom file version history UI. To send this message, the FileVersionPostMessage property in the CheckFileInfo response from the host must be set to true. Otherwise, the online office will not send this message.
This message is posted when the user activates the Share UI in the online office. The host should use this message to trigger any custom sharing UI. To send this message, the FileSharingPostMessage property in the CheckFileInfo response from the host must be set to true. Otherwise, the online office will not send this message.
Please note that the PostMessage messages have the higher priority than the CloseUrl, HostEditUrl, FileSharingUrl, FileVersionUrl properties provided in CheckFileInfo.