Content Document Iframe always empty with GECKO FX c#

178 Views Asked by At

Good morning all

I have this concern that I cannot understand. Here is my code:

        foreach (GeckoIFrameElement _E in wb.Document.GetElementsByTagName("iframe"))
                {
                    if (_E.Name == NameIframe)
                    {
                        try
                        {
                            var innerHTML = _E.ContentDocument;
                            if (innerHTML != null)
                            {
                                foreach (GeckoHtmlElement _A in innerHTML.GetElementsByTagName(BaliseRecherche))
                                {
                                    MessageBox.Show(_A.GetAttribute(AttributRecherche));
                                }
                            }

                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message);
                        }
                    }
                }

The innerthml is still empty even though my page is correctly loaded and displayed?

Thank you in advance for your replies

1

There are 1 best solutions below

0
wp78de On

Try to get teh iframe DOM:

string content = null;
var iframe = browser.Document.GetElementsByTagName("iframe").FirstOrDefault() as Gecko.DOM.GeckoIFrameElement;
if (iframe != null)
{
    var html = iframe.ContentDocument.DocumentElement as GeckoHtmlElement;
    if (html != null)
        content = html.OuterHtml;
}