net制作超简单浏览器代码

浩浩愁 发布于2011-5-20 7:34:8 分类: 编程开发 已浏览loading 网友评论0条 我要评论

 

 private void toolStripButton1_Click(object sender, EventArgs e)
        {//前进
            webBrowser1.GoBack();

        }

        private void toolStripButton2_Click(object sender, EventArgs e)
        {//后退
            webBrowser1.GoForward();
        }

        private void toolStripButton3_Click(object sender, EventArgs e)
        {//刷新
            webBrowser1.Refresh();
        }

        private void toolStripButton6_Click(object sender, EventArgs e)
        {//停止
            webBrowser1.Stop();
        }

        private void toolStripButton4_Click(object sender, EventArgs e)
        {//主页
            webBrowser1.GoHome();
        }

        private void toolStripTextBox1_Click(object sender, EventArgs e)
        {//地址栏 回车事件
            toolStripTextBox1.Text ="";
           
        }

        private void toolStripButton5_Click(object sender, EventArgs e)
        {//转到
            string adress = toolStripTextBox1.Text;
            if (adress != "")
            {
                if (adress.StartsWith("http://"))
                {
                    adress = "http://" + adress;
 
                }
                webBrowser1.Navigate(adress);

            } string title = webBrowser1.DocumentTitle;
            if (title == "")
                this.Text = adress;
            else
                this.Text = title;
         
        
            //this.Text = webBrowser1.DocumentTitle;
        }

        private void toolStripTextBox1_KeyPress(object sender, KeyPressEventArgs e)
        {//回车键
            if (e.KeyChar == (char)Keys.Enter)
            {
                string adress = toolStripTextBox1.Text;
                if (adress != "")
                {
                    if (adress.StartsWith("http://"))
                    {
                        adress = "http://" + adress;

                    }
                    webBrowser1.Navigate(adress);
                    string title = webBrowser1.DocumentTitle;
                    if (title == "")
                       this.Text = adress;
                    else
                      this.Text = title;
                }
               
            }
        }

 

已经有(0)位网友发表了评论,你也评一评吧!

原创文章转载请注明引自浩浩愁的博客! http://www.cone.cc/ 欢迎订阅浩浩愁的博客!

关于 net  的相关文章

  • 记住我的信息,下次不用再输入 不会设置评论的头像?点这里