I'm trying to load a web viewer that automatically, as the program starts, loads a url.
I've tried:
this.webBrowser1.Navigate("http://www.microsoft.com");
some code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void WebBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
this.webBrowser1.Navigate("http://www.microsoft.com");
}
}
}
I expect that when the brogram runs, that the web viewer automatically goes to a url.
Try this code inside Form1_Load
// for initial loading of the page this doesn't have to be true, this is only for navigation after loading the 1st page
webBrowser1.AllowNavigation = true;
webBrowser1.DocumentCompleted += new
WebBrowserDocumentCompletedEventHandler(WebBrowser1_DocumentCompleted);
webBrowser1.Navigate("http://www.microsoft.com");
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.