简体   繁体   English

如何将 HTML webresource 中的值传递给 window 上的 javascript 关闭 MSCRM

[英]How to pass values from HTML webresource to javascript on window close MSCRM

I am opening HTML webresource using Xrm.Navigation.openWebResource but on closing of HTML window I want to pass values from HTML to javascript file from where it is opened. I am opening HTML webresource using Xrm.Navigation.openWebResource but on closing of HTML window I want to pass values from HTML to javascript file from where it is opened. Is there call back function can be implemented?有没有回调function可以实现?

If I open HTML window using window.open I can call parent javascript function using window.opener.functionname on close but click but I want to know how I can pass values to parent javascript file on close button click of HTML window. If I open HTML window using window.open I can call parent javascript function using window.opener.functionname on close but click but I want to know how I can pass values to parent javascript file on close button click of HTML window.

I tried with window.parent.opener.Functionname() but it is not working - getting functionname is undefined but it is defined in parent javascript.我尝试使用window.parent.opener.Functionname()但它不起作用 - 获取functionname is undefined但它在父 javascript 中定义。 Pls suggest.请建议。

If you're using the 'old' (as it not the unified interface) user interface with turboforms enabled then the parents javascript is actually in a extra iframe called customScriptFrame, and not on the parent itself.如果您使用启用了 turboforms 的“旧”(因为它不是统一的界面)用户界面,那么父级 javascript 实际上位于名为 customScriptFrame 的额外 iframe 中,而不是父级本身。

To call something on the parent you can use要调用父母的东西,你可以使用

parent.customScriptsFrame.functionname() for IE

and

parent.customScriptsFrame.contentWindow.functionname() on chrome.

On the unified interface its much the same, but far more troublesome.在统一界面上它几乎相同,但要麻烦得多。 Now the scripts are in a iframe called ClientApiFrame_[n] where [n] is some random number.现在脚本位于名为 ClientApiFrame_[n] 的 iframe 中,其中 [n] 是某个随机数。 And i haven't found a good way to determin that number ahead of time from a webresource.而且我还没有找到一种从网络资源中提前确定该数字的好方法。 You could go over all frames of the parent in javascript (parent.frames) to find one that has a id that starts with ClientApiFrame_ but that will throw errors trying to read frames with sources set to external domains, and i dont think is very good practice.您可以 go 在 javascript (parent.frames) 中的父级的所有帧上找到一个 ID 以 ClientApiFrame_ 开头的帧,但这会在尝试读取源设置为外部域的帧时抛出错误,我认为这不是很好实践。

Another possibility is registering the function you want to call with the parent ahead of time.另一种可能性是注册您想提前与父母通话的 function。 so in the main javascript use this.所以在主要的 javascript 中使用这个。

parent.functionname = functionname

And then from the webResource you can use the normal然后从 webResource 你可以使用正常的

parent.functionname

If the webresource is embedded in the form, then use window.parent如果 webresource 嵌入在表单中,则使用window.parent

If you Xrm.Navigation.openWebResource to open it, then use window.opener如果你Xrm.Navigation.openWebResource来打开它,那么使用window.opener

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM