1

我正在 c# 中创建一个包含“geckoWebBrowser”的应用程序。但我必须等待网页加载完成,然后继续执行其他指令。有类似 WebBrowser.ReadyState 的东西吗?非常感谢您

4

2 回答 2

1

Hi GeckoWebBrowser has a DocumentCompleted event you could use it.

Edit:

for example you have a button to show url

private void ShowBtnClick(object sender, EventArgs e)
{
     geckoWebBrowser1.Size = new Size(int.Parse(ViewportWidth.Text), int.Parse(ViewportHeight.Text));

     geckoWebBrowser1.DocumentCompleted += LoadingFinished;

     geckoWebBrowser1.Navigate(PageUrl.Text);
}

private void LoadingFinished(object sender, EventArgs args)
{
    GeckoElement body = geckoWebBrowser1.Document.GetElementsByTagName("body")[0];
    body.SetAttribute("style", "margin-top:-700px");
}
于 2012-06-16T14:00:23.997 回答
1

尝试这个 :

private void WaitBrowser(Gecko.GeckoWebBrowser wb)
    {
        while (wb.IsBusy)
        {
            Application.DoEvents();
        }
    }
于 2013-08-29T11:59:27.923 回答