简体   繁体   中英

C# WebBrowser control problem

I'm using the webBrowser control to surf to a page that has an Iframe. I access the Iframe object like this:

WebBrowser1.Document.Window.Frames["IFrameName"] 

The problem is that sometimes the Frames collection has no frames and sometimes it does.

What might be the reason that the same exact code one time works fine and i get the iframe and few minutes later it's throwing an exception because the frame is not there?

AT what point are u making the call to the Frames collection? Are you doing this after the DocumentCompleted event?

That could make a difference ... you could handle the documentcompleted event and only make the call after the document has loaded.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM