Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

iFrame onReadyStateComplete Issue in CRM online

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Since Update 1 for MS CRM 2015 online i've got an issue with the onReadyStateComplete events in iframes.

For testing  i defined an almost empty html webresource which i placed in an Iframe on the contact form. When i open contacts i'll see this weppage correctly, but when  i add a handler for onReadyStateComplete to the defined iframe and call a js method which does nothing else than just open an alert nothing happens when the content of the iframe is loaded (handler is for sure activated).

When i call the same js method from form onload everything works so ist not a problem with that simple javascript. Even switching to the old rendering engine won't fix my problem. In all cases it seems like that the event is not thrown (worked perfectly before update). Tried now many things to get that working again but up to now i have no clue. Security for the iFrame is set like before  ... no restrictions on Overall Frame scripting (checkbox not set).

Hopefully somebody can help me with that problem.

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: iFrame onReadyStateComplete Issue in CRM online

    Sorry ... haven't found any solution up to now ... switching to the old renderung engine doesn't help me either

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: iFrame onReadyStateComplete Issue in CRM online

    Hi Sven - have you found any resolution to this issue yet?  I am experiencing the same exact issue (I think) - see my post here:   

    http://stackoverflow.com/questions/32491243/onreadystatecomplete-does-not-fire-on-iframe

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: iFrame onReadyStateComplete Issue in CRM online

    Nobody there who is able to help? Nobody there with the same Problem?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: iFrame onReadyStateComplete Issue in CRM online

    Think i should talk a bit more in Detail that you understand my Problem in our solution. I migrated a CRM 2011 onpremise to CRM 2015 online and the view for actvities in contact is not that was it has been before. So what is did was the following:

    1) Deleted the old activities from the form

    2) Inserted a new iframe with src about:blank

    3) When the iframe ready Event appeared it called ajs method to set a new source in the iframe (Areas.apsx with certain Parameters i calculated) . This Event was fired when the Rendering engine was ready ... so that i was able to use Access to DOM and Change the src attribute of the iframe

    4) What also happend was that i parsed the dom of that new view (Activities) to Change the filter to all instead of Default behaviorur (30 days) and that worked perfectly

    The example above is just a simple Showcase where i was explaining that the readystatecomplete event is not fired by update 1. My webressource i defined in this example (the blank page) is now Areas.aspx with certain paremetern where i CAN'T add any JavaScript funtionality.

    For sure i can use the form onload functionaliy of contact to set the source of the iframe here with

    var iFrame = Xrm.Page.ui.controls.get("IFRAME_ActivitiesContact");

    iFrame.setSrc(mycalculatedurl);

    But as the page is still reandering i can't force any filter in the activities to be set (aynchronus). Therefore i needed that readystatecomplete event of the iframe witch is not fired anymore.

    Do you understand what i mean?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: iFrame onReadyStateComplete Issue in CRM online

    you can add globalcontext reference to your html webresource and use your scripts.

    <script src="../ClientGlobalContext.js.aspx" type="text/javascript"></script>

    Simply add above to your html web resource to get context.

    Mansoor

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: iFrame onReadyStateComplete Issue in CRM online

    What i did was just to test issues ... before update i haven't even used the html webressource ... about:blank was also working for me

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: iFrame onReadyStateComplete Issue in CRM online

    For sure i can do ... got then your "completed" message (as expected). Problem is ... i can't place my js code here because it is in a more global context

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: iFrame onReadyStateComplete Issue in CRM online

    Hi,

    Can you please do something like below in your html web resource.

    <script type="text/javascript">

        document.onreadystatechange = function () {

            if (document.readyState == "complete") {

              alert("Completed");

            }

        }

    </script>

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: iFrame onReadyStateComplete Issue in CRM online

    I'm using Standard funtionality. Added an iFrame to the contact form with name iFrame_test and URL https://....../WebResources/test_blankPage and scripting flag disabled to get around security issues if needed.

    Content of the webressource test_blankPage is:

    <html><head><meta charset="utf-8"></head><body><font face="Arial" size="1">Loading ...</font></body></html> 

    which was created by the normal WYSYWYG Editor.

    When i save and publish this the webresource it is perfectly shown in the contact form. What i now want is that when content of the iframe is loaded (the webressource above) some JavaScript is executed.

    In my example i added a js webressource with only one function

    function showMessage() {

              alert('iframe ready');
    };

    That also has been saved and published!

    When you then go to the form properties add the above javasript webressource to your libraries and then add the eventhandler to call the method showMessage when the onload Event of the form is fired .... then the alert appears.

    When you instead use the iframe_test as source control (instead of form) and you create a handler for doing the same stuff when the readystatecomplete Event is fired you won't see an alert appearing.

    Nothing has really changed and before updating to "Update 1" it worked. But as i said ... it feels like having no event has been fired.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: iFrame onReadyStateComplete Issue in CRM online

    Can you please post the sample code which you are using in handler ?

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,160 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,962 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans