1

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?

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. Pls suggest.

1
  • Did you try my answer? Commented Nov 9, 2019 at 12:14

2 Answers 2

1

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.

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. 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.

Another possibility is registering the function you want to call with the parent ahead of time. so in the main javascript use this.

parent.functionname = functionname

And then from the webResource you can use the normal

parent.functionname
Sign up to request clarification or add additional context in comments.

1 Comment

Is this supported?
0

If the webresource is embedded in the form, then use window.parent

If you Xrm.Navigation.openWebResource to open it, then use window.opener

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.