how to use Mozilla ActiveX Control (axMozillaBrowser1) c#/.net

*爱你&永不变心* 提交于 2019-12-12 05:49:15

问题


i am trying to reload a web page 3 times using "axMozillaBrowser1(Mozilla ActiveX Control)" but axMozillaBrowser1 control is not loading web page and it's waiting courser is blinking regular but browser control is not loading web page.

Please tell me how to use axMozillaBrowser1 control properly. Thanx in advance.

this is my program code:

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);
    }
}

回答1:


Why you want to Navigate 3 times ?

But my suggest is :

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; 
        }

    }
}


来源:https://stackoverflow.com/questions/12098798/how-to-use-mozilla-activex-control-axmozillabrowser1-c-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!