傳回代表 IFRAME 或 Web 資源的內容視窗。
備註
此方法僅在 統一介面上受支援。
支援的控制項類型
iframe、網頁資源
語法
formContext.getControl(arg).getContentWindow().then(successCallback, errorCallback);
參數
| 名稱 | 類型 | 為必填項目 | Description |
|---|---|---|---|
successCallback |
功能 | 否 | 操作執行成功時要呼叫的函數。 代表 IFRAME 或 Web 資源的內容視窗實例會傳遞至函式。 |
errorCallback |
功能 | 否 | 作業失敗時要呼叫的函式。 |
傳回值
成功時,會傳回包含代表 IFRAME 或 Web 資源的內容視窗實例的 Promise。
Example
下列範例顯示如何將此方法與 HTML Web 資源 (new_myWebResource.htm) 搭配使用。
首先,在您的 HTML Web 資源中新增以下程式碼:
// This script should be in the HTML web resource.
function doStuff() {
// Add desired script logic that executes on form load.
}
接下來,在表單 OnLoad 事件處理常式中新增下列程式碼:
// This should be in a script loaded on the form.
// form_onload is a handler for the form onload event.
function form_onload(executionContext) {
var formContext = executionContext.getFormContext();
var wrControl = formContext.getControl("WebResource_CustomName");
if (wrControl) {
wrControl.getContentWindow().then(
function (contentWindow) {
contentWindow.doStuff();
}
)
}
}
如果需要初始化,則應該將類似的初始化程式碼新增至 TabStateChange 事件 處理常式。 如果重複使用,任何初始化程式碼都應該是冪等的。 基於效能考量,表單可能會在索引標籤導覽期間終結並重新初始化控制項。