webbrowser1.Navigate(string urlString) ; 给该控件设置要显示的网址
webbrowser1.GoBack(); 返回上个网页
webbrowser1.GoForward(); 前进
webbrowser1.Refresh(); 刷新
webbrowser1.Stop(); 停止
————————————————
使用StringBuilder写一个表格[
](https://www.bilibili.com/video/BV1FJ411W7e5?p=228&spm_id_from=pageDriver)
属性:
Url:指定Web浏览器控件导航到的URL。
ScriptErrorsSuppressed:指定WebBrowser控件是否存在对话框显示脚本错误。
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnEnter_Click(object sender, EventArgs e)
{
if (textBox1.Text=="")
{
webBrowser1.Navigate("http://www.baidu.com");
}
else
{
//利用构造函数将String传入uri实例中
//webBrowser1.Url需要一个uri类型
Uri uri = new Uri("http://" + textBox1.Text);
webBrowser1.Url = uri;
}
}
private void Form1_Load(object sender, EventArgs e)
{
Uri uri = new Uri("http://www.baidu.com");
webBrowser1.Url = uri;
}
private void label1_Click(object sender, EventArgs e)
{
//Uri uri = new Uri("https://6pz27.com/index.html");
//webBrowser1.Url = uri;
if (label1.Text == "网址:")
{
Uri uri = new Uri("https://6pz27.com/index.html");
webBrowser1.Url = uri;
label1.Text = "秘密网址:";
}
else if (label1.Text == "秘密网址:")
{
Uri uri = new Uri("https://www.baidu.com");
webBrowser1.Url = uri;
label1.Text = "网址:";
}
}
private void toolStripMenuItem2_Click(object sender, EventArgs e)
{
Uri uri = new Uri("https://www.961dd.com");
webBrowser1.Url = uri;
label1.Text = "秘密网址:";
}
private void toolStripMenuItem3_Click(object sender, EventArgs e)
{
Uri uri = new Uri("https://yaoporn.xyz");
webBrowser1.Url = uri;
label1.Text = "秘密网址:";
}
private void toolStripMenuItem4_Click(object sender, EventArgs e)
{
Uri uri = new Uri("https://www.txtv123.com");
webBrowser1.Url = uri;
label1.Text = "秘密网址:";
}
private void btnForward_Click(object sender, EventArgs e)
{
webBrowser1.GoForward();
}
private void btnBack_Click(object sender, EventArgs e)
{
webBrowser1.GoBack();
}
private void btnRefresh_Click(object sender, EventArgs e)
{
webBrowser1.Refresh();
}
private void btnStop_Click(object sender, EventArgs e)
{
webBrowser1.Stop();
}
private void label2_Click(object sender, EventArgs e)
{
//webBrowser1.GoHome();
webBrowser1.Navigate("http://www.baidu.com");
}
}