Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Suggested answer

Access IFrame div text

Posted on by 15

Hi all,

In dynamic crm , I have loaded iframe from other website and submit iframe form  but i am not able get success message from iframe div .

I have try following:


parent.Xrm.Page.getControl("WebResource_commonIframe").getObject().contentWindow.document.getElementById('content');

$("#WebResource_commonIframe").contents().find('body');

any above solution is not working

please suggest me any solution.

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Access IFrame div text

    Try this.

    var t = Xrm.Page.getControl("WebResource_mis_activityCalendar").getObject().contentDocument;
    $(t).contents().find("#refresh").trigger('click')

  • Suggested answer
    Pawar Pravin  Profile Picture
    Pawar Pravin 5,227 on at
    RE: Access IFrame div text

    Please try below code once:

    Xrm.Page.getControl("WebResource_commonIframe").getObject().contentDocument.getElementsByClassName("classnamehere")[0].value;
    
    or 
    
    Xrm.Page.getControl("WebResource_commonIframe").getObject().contentDocument.getElementById("Elementidhere")[0].value;
    

    In my case "getElementsByClassName" its working fine. 

  • cloflyMao Profile Picture
    cloflyMao 25,198 on at
    RE: Access IFrame div text

    Hi Jitendra,

    That's because web resource itself is also an iframe element.

    You could run code below to get iframe content in web resource:

    var webResourceContent = parent.Xrm.Page.getControl("WebResource_name").getObject().contentDocument;
    
    var iframeWebsite = webResourceContent.getElementsByTagName("iframe")[0];
    
    try {
    
      var innerDoc = iframeWebsite.contentDocument || iframeWebsite.contentWindow.document;
    
    } catch (e) {
    
      Xrm.Utility.alertDialog("An error has occured: "   e);
    
    }

    However, your "other website" might blocks external website to access its content from an iframe, such as bing.com

    pastedimage1576056392652v1.png

    Regards,

    Clofly

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans