Why is WebBrowser_DocumentCompleted() firing twice?

前端 未结 9 1331
独厮守ぢ
独厮守ぢ 2020-11-29 08:35

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 webBrow         


        
9条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-29 09:16

    if (browser.ReadyState != WebBrowserReadyState.Complete) is recommended.

    And when there are frames in the page,DocumentCompleted will be fired several times.And this is difficult to solve.Some ways like checking the urls are not accurate.

    BTW, why not using this:

    this.Text = stringA + " - " + webBrowser1.Document.Domain;

    Try to using a fixed prefix,problem may be solved easily.

提交回复
热议问题