[英]Determine if WebBrowser Successfully loaded a page
Is there an easy way to find out if a WPF WebBrowser successfully loaded a page?有没有一种简单的方法可以确定 WPF WebBrowser 是否成功加载了页面? I was able to figure out a workaround for HTML documents.我能够找到 HTML 文档的解决方法。 It requires that I add the MSHTML reference to my DLL.它要求我将 MSHTML 引用添加到我的 DLL。 I've been testing the code by trying to load " http://www.google.m ".我一直在通过尝试加载“ http://www.google.m ”来测试代码。 I used a non-existant website on purpose.我故意使用了一个不存在的网站。
Browser.LoadCompleted += HandleLoaded;
private void HandleLoaded(object sender, NavigationEventArgs e)
{
if (_browser.Document is mshtml.HTMLDocument doc)
{
if (doc.title == "Navigation Canceled")
{ HandleInvalidAddress(); }
}
}
You want to read the ReadyState .您想阅读ReadyState 。 It returns a WebBrowserReadyState value .它返回一个WebBrowserReadyState 值。 You're looking for "Complete".您正在寻找“完成”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.