Skip to main content

Mount Document

The mount node refers to the HTML DOM node where the document application is mounted when inserted into the page. When the SDK is initialized, it will automatically insert an iframe element under the mount node and render the document application in this iframe element.

Syntax

ZOfficeSDK.mount(url, selector, bAsync, config)

Return Value

Application: Document type application object

  • Excel: Excel.Workbook
  • Word: Word.Document
  • PDF: PDF.Pdf

Parameters

PropertyData TypeRequiredDescription
urlstring | objectYesAddress of the document to be mounted. This parameter can also be an object. See Other forms of the url parameter
selectorstringYesSelector of the DOM node to mount the document
bAsyncbooleanNotrue means return Application before the document is loaded, but you need to call the Application.ready() method to wait for the document to load before using advanced APIs (recommended to pass true, return available Application earlier before document content is loaded, avoiding long waiting time)
configJSONNoCan customize initialization to show/hide page components

Example

Taking mounting a spreadsheet document with address http://172.16.22.98/docs/app/thirdparty-rest/1347466381985058817/edit/content?zdocs_access_token=653b90d845a785e3c69aeba as an example

<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>JSSDK</title>
</head>

<body>

<div id="doc1" class="doc-container"></div>

<script src="sdk address"></script>
<script>
window.onload = async function() {
const Application = await ZOfficeSDK.mount('http://172.16.22.98/docs/app/thirdparty-rest/1347466381985058817/edit/content?zdocs_access_token=653b90d845a785e3c69aeba', '#doc1', true);
await Application.ready();
const sheets = await Application.ActiveWorkbook.getSheets()
console.log(sheets);
}
</script>
</body>
</html>

Other forms of the url parameter

The url parameter supports two additional object forms:

Form 1 (since v8.2): Use POST to open the document (Standard Integration)

If url is a string, the SDK will send a GET request to open the document platform page.

If you want the SDK to send a POST request, pass an object in the following format. Parameters will be sent in the request body.

This form is only applicable to Standard Integration. For related concepts, see Security.

{
url: 'The online document page URL (without query parameters)',
access_token: 'The token required by your third-party system',
optional_custom_param1: '',
optional_custom_param2: '',
// ...
}

Form 2 (since v8.1): Frontend SDK integration configuration object

When using Frontend SDK Integration, you should use a configuration object instead of url. See Edit Example and Config.