嗯,我用一个简单的WebBrowser控件来浏览网页,所以我需要改变窗体的文本,而这样做。我使用 -
Well, I'm using a simple webbrowser control to browse to a page, so I need to change the Text of the form while doing so. I'm using -
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
this.Text += " - " + webBrowser1.Document.Domain;
}
但使用断点,我注意到,这一事件被解雇两次。我甚至尝试 _Navigated()
事件。这也触发了两次。得到的标题韦伯 - google.co.in - google.co.in
..
but using a breakpoint, i noticed that, this event is firing twice. I even tried _Navigated()
event. it also fired twice. Resulting the title to "Webber - google.co.in - google.co.in"
..
我也注意到,本次活动数次在加载msn.com ..我试图改变只有当页面完成加载完全形式的文本。
I also noticed that this event fired several times while loading msn.com.. I'm trying to change the text of the form only when the page has finished loading totally..
任何补救措施?
您可以检查时,在事件被触发的WebBrowser.ReadyState:
You can check the WebBrowser.ReadyState when the event is fired:
if (browser.ReadyState != WebBrowserReadyState.Complete)
return;
readyState的将被设置为完成一次整个文件已准备就绪。
ReadyState will be set to Complete once the whole document is ready.