简体   繁体   中英

How to change the web browser control properties?

I am creating a web browser using c# winform. I am using webbrowser control for this. I am using this code. This is running good so far

// Declared Variables
        private string[] SiteMemoryArray = new string[100];
        private int count = 0;

        // Page Load
        private void Form1_Load(object sender, EventArgs e)
        {
            webBrowser.Navigate("http://www.google.com/");      // Goes To A Preset Site At Run Time
            SiteMemoryArray[count] = urlTextBox.Text;           // Saves URL To Memory
        }


        // Code For The ToolStrip 

        // URL TextBox 
        private void urlTextBox_Click(object sender, EventArgs e)
        {
            urlTextBox.SelectAll();     // Selects All The Text In The urlTexBox
        }

        // GO Button
        private void goButton_Click(object sender, EventArgs e)
        {
            webBrowser.Navigate(urlTextBox.Text);       // Navigates To The Site Typed In The urlTextBox
        }

        // Back Button
        private void backButton_Click(object sender, EventArgs e)
        {
            if (count > 0)                                  // Checks To Make Sure The Count Variable Is More Then 0
            {
                count = count - 1;                          // Subtracts 1 From Count Variable 
                urlTextBox.Text = SiteMemoryArray[count];   // Replace The Text In The urlTextBox With The Last URl
                webBrowser.Navigate(urlTextBox.Text);       // Navigates To The Site Typed In The urlTextBox
                forwardButton.Enabled = true;               // Enables The forwarButton

            }
        }

        // Forward Button
        private void forwardButton_Click(object sender, EventArgs e)
        {
            if (count < 100)                                // Checks To Make Sure The Count Variable Is Less Then 100
            {
                count = count + 1;                          // Adds 1 To Count Variable
                urlTextBox.Text = SiteMemoryArray[count];   // Replace The Text In The urlTextBox With The Next URl
                webBrowser.Navigate(urlTextBox.Text);       // Navigates To The Site Typed In The urlTextBox
                backButton.Enabled = true;                  // Enables The backButton

                count = count + 1;                          // Adds 1 To Count Variable 
                if (SiteMemoryArray[count] == null)         // Checks To See If The Next Variable In The SiteMemoryArray Is Null
                {
                    forwardButton.Enabled = false;          // Disables The forwarButton
                }
                count = count - 1;                          // Subtracts 1 From Count Variable 
            }
        }

But after create this small application my friend who is php developer ask me to check browser name . For this he create a php script n give me url then i run this url on my this browser its show me the browser name Internet Explorer Now I want my browser name whatever I give name Please tell me is it possible with this control. Is there any property by using i can change it ?

The web browser control is IE. If you want to create your own browser, it is a lot more work than this. You need to write code that is able to do following and more:

  1. Understand and handle HTTP protocol.
  2. Understand, parse and render HTML. Most browsers ignore certain HTML errors and still render pages accurately. Not sure if you want that kind of features.
  3. Your application should be able apply CSS settings on the pages.
  4. Your application should be able to apply JS, flash, video, audio and other items that may well be embedded on a page.

You would also need to provide features that are available standard browsers.

The question is: What is the purpose of this application? Are you trying to write your own browser?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM