HTML - How do I know when all frames are loaded?

前端 未结 12 1287
挽巷
挽巷 2020-12-10 04:31

I\'m using .NET WebBrowser control. How do I know when a web page is fully loaded?

I want to know when the browser is not fetching any more data. (The moment when IE

12条回答
  •  执念已碎
    2020-12-10 05:20

    You will get a BeforeNavigate and DocumentComplete event for the outer web page, as well as each frame. You know you're done when you get the DocumentComplete event for the outer webpage. You should be able to use the managed equivilent of IWebBrowser2::TopLevelContainer() to determine this.

    Beware, however, the website itself can trigger more frame navigations anytime it wants, so you never know if a page is truly done forever. The best you can do is keep a count of all the BeforeNavigates you see and decrement the count when you get a DocumentComplete.

    Edit: Here's the managed docs: TopLevelContainer.

提交回复
热议问题