0

我正在尝试使用重新加载网页 3 次,"axMozillaBrowser1(Mozilla ActiveX Control)" 但 axMozillaBrowser1 控件未加载网页,它正在等待进程正在正常闪烁,但浏览器控件未加载网页。

请告诉我如何正确使用 axMozillaBrowser1 控件。提前谢谢。

这是我的程序代码:

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
        progressBar1.Maximum = 3;
    }

    private void Form1_Load(object sender, EventArgs e)
    {

    }

    private void button1_Click(object sender, EventArgs e)
    {
        do
        {
            axMozillaBrowser1.Navigate(textBox1.Text);
            while(axMozillaBrowser1.ReadyState != MOZILLACONTROLLib.tagREADYSTATE.READYSTATE_COMPLETE)
            {
                Application.DoEvents();
                if (axMozillaBrowser1.ReadyState == MOZILLACONTROLLib.tagREADYSTATE.READYSTATE_COMPLETE)
                { 
                    progressBar1.Value = progressBar1.Value + 1; 
                }
            }
        }while(progressBar1.Value != 3);
    }
}
4

1 回答 1

0

为什么要导航 3 次?

但我的建议是:

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
        progressBar1.Maximum = 3;
    }

    private void Form1_Load(object sender, EventArgs e)
    {

    }

    private void button1_Click(object sender, EventArgs e)
    {
             progressBar1.Value = 0; 
            axMozillaBrowser1.Navigate(textBox1.Text);
    }

    private void webBrowser2_Navigated(object sender, WebBrowserNavigatedEventArgs e)
    {
        if ( progressBar1.Value < 3 )
        {
            axMozillaBrowser1.Navigate(textBox1.Text);
            progressBar1.Value = progressBar1.Value + 1; 
        }

    }
}
于 2012-08-23T20:13:19.833 回答