简体   繁体   English

确定 WebBrowser 是否成功加载页面

[英]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.

相关问题 如何确定页面何时在 csharp 的 webbrowser 控件中完全加载? - how to determine when page is loaded completely in webbrowser control in csharp? 在 CefSharp webbrowser 中获取加载的页面源 - Get loaded page source in CefSharp webbrowser 在C#中将加载到WebBrowser conriol中的网页的DIR重新整理 - Incerease DPI resoultion for web page loaded into WebBrowser conriol in C# 从WebBrowser中加载的页面中的链接打开本地html文件 - Open local html file from link in page loaded in WebBrowser 检查webbrowser是否在未完成文档的情况下加载了新页面 - Check to see if webbrowser has loaded new page without document complete Webbrowser下载完成-加载页面到控件时如何调用事件? - Webbrowser downloadedcompleted - how to call event when page into control is loaded? 确定在WPF中使用WebBrowser视图时页面何时完成加载(Windows.Controls.WebBrowser) - Determine when a page has finished loading when using WebBrowser view in WPF (Windows.Controls.WebBrowser) 如何确定从Silverlight 2.0(RC0)中的URI成功加载的图像? - How do I determine an image loaded successfully from a URI in Silverlight 2.0 (RC0)? 检查 WebBrowser 是否已加载 - Checking if WebBrowser has loaded 如何确定加载的页面是否是System.Windows.Forms.WebBrowser中的错误页面或有效页面? - How to find out if the loaded page is error page or valid page in System.Windows.Forms.WebBrowser?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM