检测 WebBrowser 完成页面加载 [英] Detect WebBrowser complete page loading
问题描述
如何检测 System.Windows.Forms.WebBrowser 控件何时完成加载?
How can I detect when a System.Windows.Forms.WebBrowser control has completed loading?
我尝试使用 Navigate 和 DocumentCompleted 事件,但在文档加载期间它们都被引发了几次!
I tried to use the Navigate and DocumentCompleted events but both of them were raised a few times during document loading!
推荐答案
我认为 DocumentCompleted
事件也会被所有加载的子文档触发(例如 JS 和 CSS).您可以查看 DocumentCompleted
中的 WebBrowserDocumentCompletedEventArgs
并检查 Url 属性并将其与主页的 Url 进行比较.
I think the DocumentCompleted
event will get fired for all child documents that are loaded as well (like JS and CSS, for example). You could look at the WebBrowserDocumentCompletedEventArgs
in DocumentCompleted
and check the Url property and compare that to the Url of the main page.
这篇关于检测 WebBrowser 完成页面加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!