How to set iframe src using javascript in crm2013? RRS feed

  • Question

  • Hi 

    I am not able to set iframe src in crm2013.

    I tried with below code but it was not working for me.


    Please let me know if any one knows.

    Thanks ,

    sravan J

    Friday, September 27, 2013 1:04 PM

All replies

  • Are you getting any errors when you run that bit of code?

    Please feel free to contact me via any of the following methods:

    Sunday, September 29, 2013 8:32 PM
  • You can try using the following function:

    function SetIFrameUrl(IFrame, Url) {
        var frame = Xrm.Page.ui.controls.get(IFrame);

    Microsoft Certified Technical Specialist
    EmpowerCS (Australia) for all your CRM/SharePoint needs.

    Monday, September 30, 2013 2:12 AM
  • Hi Roshan,

    Thanq for respond to my question..

    I am not getting any error..

    Monday, September 30, 2013 12:48 PM
  • Hi Ibrahim,

    Thanq for u r reply

    I tried with u r code also.. still its not displaying any thing in that iframe...

    • Edited by sravan J Monday, September 30, 2013 12:49 PM change
    Monday, September 30, 2013 12:48 PM
  • Put your code on the forum.

    Regards Faisal

    Monday, September 30, 2013 12:58 PM
  • Were you able to resolve this?  I'm having the same problem upgrading from CRM 2011 to CRM 2013.
    Tuesday, October 29, 2013 9:11 PM
  • No David. 
    Wednesday, October 30, 2013 6:51 AM
  • //Get the value of an option set attribute
    var value = Xrm.Page.data.entity.attributes.get("new_pagechooser").getValue();
    var newTarget = "";
    //Set the target based on the value of the option set
    switch (value) {
        case 100000001:
            newTarget = "http://myServer/test/pageOne.aspx";
            newTarget = "http://myServer/test/pageTwo.aspx";
    //Get the default URL for the IFRAME, which includes the 
    // query string parameters
    var IFrame = Xrm.Page.ui.controls.get("IFRAME_test");
    var Url = IFrame.getSrc();
    // Capture the parameters
    var params = Url.substr(Url.indexOf("?"));
    //Append the parameters to the new page URL
    newTarget = newTarget + params;
    // Use the setSrc method so that the IFRAME uses the
    // new page with the existing parameters

    From the CRM 2013 SDK
    • Proposed as answer by F.Kuyler Wednesday, May 28, 2014 12:18 PM
    Thursday, October 31, 2013 8:52 AM
  • I am having the exact same problem. So far I have only tested on CRM online, but I will try to do a test on-prem tomorrow and then I will open an SR with MS as there a no solutions posted anywhere.

    Tuesday, November 5, 2013 11:10 AM
  • Did you end up having the same issue with on-premise?
    • Proposed as answer by Igor Abreu Monday, November 11, 2013 4:50 PM
    • Unproposed as answer by Igor Abreu Monday, November 11, 2013 4:50 PM
    Monday, November 11, 2013 2:35 PM
  • i'm having the same problem using on-premise, the sdk reccomends you use a follow code:


    Sets the URL to be displayed in an IFRAME or web resource.


    But i don't have sucess!
    • Edited by Igor Abreu Monday, November 11, 2013 4:53 PM
    Monday, November 11, 2013 4:52 PM
  • Hi,

    I faced this problem also, the solution is a small work around in few steps.

    1- Set IFrame URL to "about:blank".

    2-Register function for IFrame's OnReadyStateComplete as following :

    function setIFRAME_Related_PO_OnLoad() {
        var IFrame = Xrm.Page.ui.controls.get("IFRAME_Related_PO");
        var url = IFrame.getSrc();
        if (url.indexOf("blank") !== -1) {

    3-setIFRAME_Related_PO is a normal function to set url for IFrame Example Code:-

    function setIFRAME_Related_PO() {
            var url = 'www.google.com';

    I hope this be useful for you.

    Mohamed Rasheed


    Wednesday, November 13, 2013 9:26 AM
  • Brilliant, Mohamed.  This worked for me.  Thanks very much.
    Wednesday, November 13, 2013 4:56 PM
  • This doesn't work for me, I may be using the OnReadyStateComplete feature wrong.How do I register a function for OnReadyStateComplete?

    Can someone elaborate on what that is supposed to do and how it works?

    All I want to do is load a different URL into an IFrame, no luck so far.

    Friday, December 13, 2013 7:40 PM
  • DuSport, it's a bit late but select the IFram then click on "Change Properties". Navigate to the tab "Events". There you will se the OnReadyStateComplete event listed.
    Tuesday, May 20, 2014 3:56 AM