且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

WebBrowser控件-浏览页面...

更新时间:2022-02-28 00:41:55

也许这个链接可以引导您更接近您的目标. br/> 它对事件有更好的处理,并且也很好地解释了.

(这是它的介绍:
.NET的WebBrowser控件只是IE ActiveX控件的包装.但是,此包装没有公开IE ActiveX控件公开的所有事件.

< a href ="http://blogs.artinsoft.net/mrojas/archive/2008/09/18/newwindow2-events-in-the-c-webbrowsercontrol.aspx"> http://blogs.artinsoft.净/mrojas/archive/2008/09/18/newwindow2-events-in-the-c-webbrowsercontrol.aspx</a>[<a href ="http://blogs.artinsoft.net/mrojas/archive/2008/09/18/newwindow2-events-in-the-c-webbrowsercontrol.aspx"target =" _ blank"title ="新窗口> ^</a>]

我已经使用了一段时间,所以内存并不是很新鲜,但是我可以回想起,至少这有助于解决与该控件有关的基于事件的问题;)

***的问候
Andy
Hi, maybe this link might guide you closer to your goal.
It has better handling for the events and it is also explained very well.

(here is it''s introduction:
The WebBrowser control for .NET is just a wrapper for the IE ActiveX control. However this wrapper does not expose all the events that the IE ActiveX control exposes.

<a href="http://blogs.artinsoft.net/mrojas/archive/2008/09/18/newwindow2-events-in-the-c-webbrowsercontrol.aspx">http://blogs.artinsoft.net/mrojas/archive/2008/09/18/newwindow2-events-in-the-c-webbrowsercontrol.aspx</a>[<a href="http://blogs.artinsoft.net/mrojas/archive/2008/09/18/newwindow2-events-in-the-c-webbrowsercontrol.aspx" target="_blank" title="New Window">^</a>]

I used this quite a while ago so the memory isn''t really fresh, but I can recall that at least this helped me with my event based problems concerning this control ;)

best regards
Andy


这将提供一个循环"以等待新页面完全加载.如果我没记错的话,浏览器控件会发送文档完成消息,以说明许多事情(图像加载等),但是最后一个消息会在所有对象(包括框架)完成后发送.

不确定分页时的行为如何,但是如果它们具有不同的绝对地址,那应该没问题.

This will provide a "loop" to wait until a new page is fully loaded. If I''m not mistaken, the browser control sends document complete messages for a number of things (image loads, etc), but the last one it sends its when the all objects are finished (including frames).

Not sure how this will behave with paging, but if they have different absolute addresses it should be fine.

private void Browser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
    /** make sure we are only handling the event sent by the main url, not frames, etc **/
    if (!e.Url.AbsoluteUri.Equals(browser.Document.Url.AbsoluteUri))
    {
        return;
    }
}



注意:我不记得我在哪里剪到这个剪子,但是信誉不是我的



Note: I cant remember where I got this snip, but credit is not mine