Cannot access iframes

75 views
Skip to first unread message

dave...@gmail.com

unread,
Jan 28, 2014, 9:16:02 AM1/28/14
to cse...@googlegroups.com
I have tried to get at an iframe and the elements in it and have been unable.  I tried using the code here https://groups.google.com/forum/#!msg/csexwb/C2wcPlnTBJU/Si0R9s1C2iYJ but get an access exception, so I used Codecentrix's example and it does not give me an exception, but I just get the parent document back, not the iframe document.  I am attempting to read another's company's website so I have no control over the webpage.  Any help would be appreciated.  Right now my code looks like this using Codecentrix's example:

IHTMLElementCollection col = cEXWB1.GetElementsByTagName(true, "iframe");

if (col != null)

{

foreach (IHTMLElement el in col)

{

try

{

IHTMLFrameBase2 wb = (IHTMLFrameBase2)el;

IHTMLWindow2 win2 = (IHTMLWindow2)wb.contentWindow;

IHTMLDocument2 doc3 = CodecentrixSample.CrossFrameIE.GetDocumentFromWindow(win2);

                               

}

catch (Exception ex)

{

 }

}




}

}

}

Alexandr Krulik

unread,
Jan 29, 2014, 5:52:46 AM1/29/14
to cse...@googlegroups.com
hi
what you try to do?



--
You received this message because you are subscribed to the Google Groups "csEXWB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to csexwb+un...@googlegroups.com.
To post to this group, send email to cse...@googlegroups.com.
Visit this group at http://groups.google.com/group/csexwb.
For more options, visit https://groups.google.com/groups/opt_out.



--
Kind regards,
Alex Krulik

Rudolf Ngan

unread,
Mar 17, 2015, 11:32:19 AM3/17/15
to cse...@googlegroups.com
Hi,

In order to access content inside iframes / frames, you have to cast the iframe object to iwebbrowser2 class first.
Reply all
Reply to author
Forward
0 new messages