| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 919 人关注过本帖
标题:撞邪了!AxWebbrowser无法获取实时url!
只看楼主 加入收藏
炫色流年
Rank: 2
等 级:论坛游民
帖 子:61
专家分:18
注 册:2011-8-8
结帖率:38.46%
收藏
 问题点数:0 回复次数:2 
撞邪了!AxWebbrowser无法获取实时url!
程序代码:
求救!我的代码写得很清楚,导航完成后地址栏里会显示出URL,可是运行时却不是这样啊!怎么办?

 private void WebBrowser_NavigateComplete2(object sender, AxSHDocVw.DWebBrowserEvents2_NavigateComplete2Event e)
        {
            this.tool2cmbURL.Text = WebBrowser.LocationURL;
        }
我又将代码改成这样,还是没反应啊!!!!!!!!!
 private void WebBrowser_NavigateComplete2(object sender, AxSHDocVw.DWebBrowserEvents2_NavigateComplete2Event e)
        {
            tool2cmbURL.Text = (string)e.uRL;
        }


本人是在.net4.0 + win7下做的,求大虾帮助!!!!!!谢了!!!
以下为全部代码,(别看着这么多,其实都很简单,我是新人,如果你觉得代码可以改进的话,欢迎指教,qq457561647)
///////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading ;
using System.Web;
namespace Weber
{
    public partial class frmWeb : Form
    {
      
        public frmWeb()
        {
            InitializeComponent();
        }
        private void frmWeb_Load(object sender, EventArgs e)
        {
            this.WindowState = FormWindowState.Normal;           
        }
      
        private void tool1btnGoBack_Click(object sender, EventArgs e)        
{
            try
            {
                WebBrowser.GoBack();
            }
            catch
            {
                MessageBox.Show("已经是最后一页!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
         
        }
      
        private void tool1btnGoForward_Click(object sender, EventArgs e)
        {
            try
            {
                WebBrowser.GoForward ();
            }
            catch
            {
                MessageBox.Show("已经是最前一页!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
         
        }

        private void tool1btnStop_Click(object sender, EventArgs e)
        {
            if (tool2cmbURL.Text == "") return;
            if (tool2cmbURL.Text == "about:blank") return;
            WebBrowser.Stop();
         
        
        }
      
        private void tool1btnRefresh_Click(object sender, EventArgs e)
        {
            if (tool2cmbURL.Text == "") return;
            if (tool2cmbURL.Text == "about:blank") return;
            WebBrowser.Refresh2();
           
        }
      
        private void tool1btnHome_Click(object sender, EventArgs e)
        {
            WebBrowser.GoHome();
           
        }

                private void mnFileNewForm_Click(object sender, EventArgs e)
        {
            
            frmWeb NewForm = new frmWeb();
            NewForm.Show();
            NewForm.Focus();
            NewForm.WebBrowser.Navigate("about:blank");                        
        }
      
               private void WebBrowser_NavigateComplete2(object sender, AxSHDocVw.DWebBrowserEvents2_NavigateComplete2Event e)
        {
            this.tool2cmbURL.Text = WebBrowser.LocationURL;
        }
      
        private void tool2cmbURL_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)13)
            {
                tool2btnGO.PerformClick();
            }
        }
        private void tool2btnGO_Click(object sender, EventArgs e)
        {
            if (tool2cmbURL.Text == "")
            {
                MessageBox.Show("请输入网址!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (tool2cmbURL.Text == "about:blank")
            {
                MessageBox.Show("这是空白页,请输入网址!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            Cursor.Current = Cursors.WaitCursor;
            WebBrowser.Navigate(tool2cmbURL.Text);
            Cursor.Current = Cursors.Default;
        }
        private void Search(string URL, string startwords)
        {
            string searchwords = tool2txt.Text.Trim();
            if (searchwords.Length < 1)
            {
                WebBrowser.Navigate(URL);
                return;
            }
            WebBrowser.Navigate(URL + startwords + HttpUtility.UrlEncode(Encoding.Default.GetBytes(searchwords)));
        }
        private void tool2btnSearch_Click(object sender, EventArgs e)
        {
            Search("http://www.baidu.com/", "s?wd=");
        }
        private void WebBrowser_BeforeNavigate2(object sender, AxSHDocVw.DWebBrowserEvents2_BeforeNavigate2Event e)
        {
            string str = tool2cmbURL.Text.Trim();
        }
        private void WebBrowser_NewWindow2(object sender, AxSHDocVw.DWebBrowserEvents2_NewWindow2Event e)
        {
            frmWeb newwindow = new frmWeb();
            e.ppDisp = newwindow.WebBrowser.Application;
            newwindow.Show();
            newwindow.WebBrowser.RegisterAsBrowser = true;
           
        }
    }
}
搜索更多相关主题的帖子: 怎么办 void 地址栏 
2012-03-24 13:19
炫色流年
Rank: 2
等 级:论坛游民
帖 子:61
专家分:18
注 册:2011-8-8
收藏
得分:0 
大虾呢?都被鱼吃了?
2012-03-24 14:47
炫色流年
Rank: 2
等 级:论坛游民
帖 子:61
专家分:18
注 册:2011-8-8
收藏
得分:0 
斑竹,大虾在哪里???
2012-03-24 19:44
快速回复:撞邪了!AxWebbrowser无法获取实时url!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.022780 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved