3

I have placed an HTML Web Resource on my CRM Contact Form and I want to dynamically change the URL of this HTML Web Resource.

How can I set the URL of this HTML Web Resource using jScript's XRM properties? Basically I am looking for something like this:

Xrm.Page.ui.controls.get("ID of my web resource").url = "http://google.com"

I tried this and few other variants but nothing seems to work.

Note:
I am aware of the following alternate solutions for this approach but I have a specific requirement to achieve this using HTML Web Resource:
1) Using iFrame to load dynamic contents
2) By placing a JS in the HTML Web Resource's code and using location.href="my dynamic URL"

Ashish
  • 373
  • 1
  • 5
  • 15

2 Answers2

5

You need to use the setSrc method:

Xrm.Page.getControl("new_iframe").setSrc("http://www.stackoverflow.com");

MSDN reference:

http://msdn.microsoft.com/en-us/library/gg334266.aspx#BKMK_setSrc

Guido Preite
  • 14,905
  • 4
  • 36
  • 65
0

The supported way of changing the url of an embedded frame would be through an iFrame. Since this is not the desired solution, you would need to use an "unsupported" solution to accomplish this.

Here is one way you could change the url of an embedded web resource:

Xrm.Page.getControl("WebResource_NameOfResource").getObject().src = "http://google.com";
BlueSam
  • 1,888
  • 10
  • 17