Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 772953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T18:53:10+00:00 2026-05-14T18:53:10+00:00

I’m trying to programmatically load a web page via the WebBrowser control with the

  • 0

I’m trying to programmatically load a web page via the WebBrowser control with the intent of testing the page & it’s JavaScript functions. Basically, I want to compare the HTML & JavaScript run through this control against a known output to ascertain whether there is a problem.

However, I’m having trouble simply creating and navigating the WebBrowser control. The code below is intended to load the HtmlDocument into the WebBrowser.Document property:

WebBrowser wb = new WebBrowser();
wb.AllowNavigation = true;

wb.Navigate("http://www.google.com/");

When examining the web browser’s state via Intellisense after Navigate() runs, the WebBrowser.ReadyState is ‘Uninitialized’, WebBrowser.Document = null, and it overall appears completely unaffected by my call.

On a contextual note, I’m running this control outside of a Windows form object: I do not need to load a window or actually look at the page. Requirements dictate the need to simply execute the page’s JavaScript and examine the resultant HTML.

Any suggestions are greatly appreciated, thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T18:53:11+00:00Added an answer on May 14, 2026 at 6:53 pm

    You should handle the WebBrowser.DocumentComplete event, once that event is raised you will have the Document etc.

    wb.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(wb_DocumentCompleted);
    

    private void wb_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
    {
      WebBrowser wb = sender as WebBrowser;
      // wb.Document is not null at this point
    }
    

    Here is a complete example, that I quickly did in a Windows Forms application and tested.

    public partial class Form1 : Form
      {
        public Form1()
        {      
          InitializeComponent();
        }
    
        private void Form1_Load(object sender, EventArgs e)
        {
          WebBrowser wb = new WebBrowser();
          wb.AllowNavigation = true;
    
          wb.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(wb_DocumentCompleted);
    
          wb.Navigate("http://www.google.com");
    
                  }
    
        private void wb_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
          WebBrowser wb = sender as WebBrowser;
          // wb.Document is not null at this point
        }
      }
    

    Edit: Here is a simple version of code that runs a window from a console application. You can of course go further and expose the events to the console code etc.

    using System;
    using System.Windows;
    using System.Windows.Forms;
    
    namespace ConsoleApplication1
    {
      class Program
      {    
        [STAThread] 
        static void Main(string[] args)
        {      
          Application.Run(new BrowserWindow());   
    
          Console.ReadKey();
        }
      }
    
      class BrowserWindow : Form
      {
        public BrowserWindow()
        {
          ShowInTaskbar = false;
          WindowState = FormWindowState.Minimized;
          Load += new EventHandler(Window_Load);
        }
    
        void Window_Load(object sender, EventArgs e)
        {      
          WebBrowser wb = new WebBrowser();
          wb.AllowNavigation = true;
          wb.DocumentCompleted += wb_DocumentCompleted;
          wb.Navigate("http://www.bing.com");      
        }
    
        void wb_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
          Console.WriteLine("We have Bing");
        }
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 413k
  • Answers 413k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If you're loading the page CMS-style presumably you've got some… May 15, 2026 at 8:19 am
  • Editorial Team
    Editorial Team added an answer You probably want to start a screen. Try typing screen… May 15, 2026 at 8:19 am
  • Editorial Team
    Editorial Team added an answer var limits the scope of a variable to the function… May 15, 2026 at 8:19 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.