web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How to refresh iFrame source

(0) ShareShare
ReportReport
Posted on by 4,130

Hi,

I have a custom entity with 2 tabs, each tab contain an iFrame linked to a custom pages

I want when I change something in one of the tabs (under iFrame1 for example) to be reflected automatically when I click on the other tab under iFrame2

How do I refresh the other iFrame source?

Or how do i add code when clicking on any of the tab 

 

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Vipin J Profile Picture
    1,603 on at
    RE: How to refresh iFrame source

    here is a code to Refresh an IFRAME...

     

    var currentLocation = Xrm.Page.getControl("controlname").getObject().contentWindow.location.href;
    Xrm.Page.getControl("controlname").getObject().contentWindow.location.href = currentLocation;

    You can create a Dummy Boolean field which you need to update whenever you are making any changes in any of your IFrames.

    Then you need to write a code on the change of this dummy field to Refresh an IFrame content.

  • Suggested answer
    ashlega Profile Picture
    34,477 on at
    RE: How to refresh iFrame source

    Hi,

     you might try using HTML5 postMessage, especially if those iframes are loading data from different domains:

    davidwalsh.name/window-postmessage

  • Suggested answer
    Syed Ibrahim Profile Picture
    6,257 on at
    RE: How to refresh iFrame source

    You can add a  button the html webresource to refresh upon onlclick without refreshing the whole page.

    You can use the below code:

    <html>

    <body>

    <button onclick="myFunction()">Reload page</button>

    <script>

    function myFunction() {

       location.reload();

    }

    </script>

    </body>

    </html>

  • Suggested answer
    Aric Levin - MVP Profile Picture
    30,190 Moderator on at
    RE: How to refresh iFrame source

    In iFRAME2:

    parent.Xrm.Page.getControl("IFRAME1").getObject().contentWindow.location.reload();

    Notice the need for parent, as you are doing this inside of a web resource.

    You can also create a function called RefreshIFrame on the entity script library, which will refresh the IFRAME:

    function RefreshIFrame(iFrameName)

    {

      Xrm.Page.getControl(iFrameName).getObject().contentWindow.location.reload();

      // or you can use the location.href as mentioned earlier

    }

    Call that function from the IFRAME itself:

    parent.window.RefreshIFrame("IFRAME2")

    If you have issues calling that function you can add it to the Xrm so that it is visible from within IFRAME (Might not be supported):

    community.dynamics.com/.../calling-custom-javascript-function-from-web-resource-on-parent-page

    Hope this helps.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#1
UllrSki Profile Picture

UllrSki 2

#3
ED-30091530-0 Profile Picture

ED-30091530-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans