locked
Set Iframe dynamically on form load crm 2013 RRS feed

  • General discussion

  • Hi all,

    I am unable to set Iframe url dynamically on form load.

    I have a field in my Opportunity form named "URL" and I have an Iframe named "IFrame_URL".

    And what I want is to set the IFrame_URL with the url that is on the custom field "URL" when the form load.

    Can anyone guide me please?

    Many Thanks

    REgards

    Vinay

    Tuesday, November 26, 2013 1:10 PM

All replies

  • Hi,

    Try this :

    var URL=Xrm.Page.getAttribute("new_url").getValue();
    Xrm.Page.getControl("IFRAME_URL").setSrc(URL);


    Hope this helps. If you get answer of your question, please mark the response as an answer and vote as helpful !!!
    Vikram Singh. !!!  My Blog

    Tuesday, November 26, 2013 1:16 PM
  • Hi Vikram,

    I have tried it but it doesnot work.

    When I open the form, the IFrame displays blank page.

    any other option?

    Thanks

    Wednesday, November 27, 2013 6:09 AM
  • Hi Vinay,

    Please re-check Iframe name and URL on the field should be correct.

    And also, try to debug your code and make sure your code lines executing through.


    Hope this helps. If you get answer of your question, please mark the response as an answer and vote as helpful !!!
    Vikram Singh. !!!  My Blog

    Wednesday, November 27, 2013 6:13 AM
  • Hi Vikram,

    My function is as below:

    The default url of the IFrame is set to: about:blank

    function dSPoint()
    {
    var URL=Xrm.Page.getAttribute("new_sharepointurl").getValue();

    Xrm.Page.getControl("IFRAME_SPoint").setSrc(URL);

    alert ("SharePoint URL: "+URL);

    }

    I am calling it on form load.

    The code is executing as the popup alert is returning the url.

    Have u tried it.

    Wednesday, November 27, 2013 6:25 AM
  • Hi Vinay

    You need to clear restrict cross-site scripting on your iframe. To do this, double-click on the iframe on the customize your form and you will see a checkbox to restrict cross-site scripting. Clear that check box publish it and try again.


    I hope this helps. If my response answered your question, please mark the response as an answer and also vote as helpful.
    Mubasher Sharif
    Check out my about.me profile!
    http://mubashersharif.blogspot.com
    Linked-In Profile
    Follow me on Twitter!

    Wednesday, November 27, 2013 6:28 AM
  • I have alraedy done it.

    Still no luck.

    Wednesday, November 27, 2013 6:36 AM
  • HI all,

    It seems that setting Iframe on Form load, does not work as per url below:

    http://social.msdn.microsoft.com/Forums/live/en-US/d7b0734a-145d-4a9b-ba52-d0bef5a8067f/change-the-source-of-iframe-in-crm-2013-to-display-another-page-aspx?forum=crm

    But it's annoying, everytime it refreshes the iframe.

    Is there a solution where I can set the IFrame to refresh only once?

    Many Thanks

    Vinay

    Thursday, November 28, 2013 5:47 AM
  • Please share your code.

    Hope this helps. If you get answer of your question, please mark the response as an answer and vote as helpful !!!
    Vikram Singh. !!!  My Blog

    Thursday, November 28, 2013 6:24 AM
  • Hi,

    Please find my code below:

    function Frame_change()
    {
     
    var spurl=Xrm.Page.getAttribute("new_sharepointurl").getValue();
          
     var IFrame = Xrm.Page.ui.controls.get("IFRAME_SPoint");    
          IFrame.setSrc(spurl);    
    }

    function Form_onLoad() 
    {
    setInterval("Frame_change()", 200000);
    }

    Thanks & Regards

    Vinay

    Friday, November 29, 2013 7:00 AM