getContentWindow (Client API reference)
Returns the content window that represents an IFRAME or web resource.
Note
This method is supported only on Unified Interface.
Control types supported
iframe, web resource
Syntax
formContext.getControl(arg).getContentWindow().then(successCallback, errorCallback);
Parameters
Name | Type | Required | Description |
---|---|---|---|
successCallback |
Function | No | A function to call when operation is executed successfully. A content window instance representing the IFRAME or web resource is passed to the function. |
errorCallback |
Function | No | A function to call when the operation fails. |
Return Value
On success, returns a promise that contains a content window instance representing an IFRAME or web resource.
Example
The following example shows how you can use this method with an HTML Web resource (new_myWebResource.htm).
First, add the following code in your HTML web resource:
// This script should be in the HTML web resource.
// No usage of Xrm or formContext should happen until this method is called.
function setClientApiContext(xrm, formContext) {
// Optionally set Xrm and formContext as global variables on the page.
window.Xrm = xrm;
window._formContext = formContext;
// Add script logic here that uses xrm or the formContext.
}
Next, add the following code in the form OnLoad event handler:
// 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.setClientApiContext(Xrm, formContext);
}
)
}
}
Similar initialization code should be added to a TabStateChange event handler if such initialization is necessary. Any initialization code should be idempotent if it's reused. For performance reasons, the form may destroy and reinitialize the control during tab navigation.
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기