“WebBrowser”控件是不是根据网址,在浏览器中打开网页啊???也就是“webBrowser1.Navigate(new Uri("www.csdn.com", UriKind.RelativeOrAbsolute));”,是不是可以在浏览器中打开CSDN.如果不可以,那么要在软件中知道百度地址,怎样用webBrowser打开呢???
解决方案 »
- 如何动态添加网页标题 C# .NET
- 关于combobox的问题
- 写个Hello World, 理解下IoC DI 不知正确与否, 请各位指教 不胜感激!
- OdbcConnection 连接字符串的路径部分带有空格 (急,在线等)
- C#分秒怎么转换成毫秒
- GraphicsPath ,怎么把里面的各个图形坐标取出来,然后再更改里面的坐标
- winform中的datagrid自动调整列宽的问题.size = g.MeasureString(dataGrid1[i,col].ToString(),dataGrid1.Font,500,sf);老出现异常.该怎
- 请问能否调用由Delphi编写的Dll动态连接库?
- 求大神看看哪里错了,数据库插不进去
- c# 如何让窗体指定位置产生滚动条而不是窗体边缘
- windows phone 7 不支持非托管代码?
- winform里 imagelist里的图片怎么样在richtextbox里显示呢?
webBrowser1.Navigate(textBox1.Text);
textBox1里面写着想要浏览的网址
public BrowserPage()
{
InitializeComponent();
this.Loaded += new RoutedEventHandler(BrowserPage_Loaded);
}
private void BrowserPage_Loaded(object sender, RoutedEventArgs e)
{
if (NavigationContext.QueryString.Count > 0)
{
string url = "http://www.google.com"
webBrowser1.Navigate(new Uri(url, UriKind.RelativeOrAbsolute));
}
}
{
InitializeComponent();
Browser.Navigated += new EventHandler<System.Windows.Navigation.NavigationEventArgs>(Browser_Navigated);
Browser.Navigating += new EventHandler<NavigatingEventArgs>(Browser_Navigating);
Browser.ScriptNotify += new EventHandler<NotifyEventArgs>(Browser_ScriptNotify);
this.Loaded += new RoutedEventHandler(BrowserPage_Loaded);
} void Browser_ScriptNotify(object sender, NotifyEventArgs e)
{
Browser.Navigate(new Uri(e.Value, UriKind.Absolute));
} void Browser_Navigating(object sender, NavigatingEventArgs e)
{
ProgBar.Visibility = Visibility.Visible;
} void Browser_Navigated(object sender, System.Windows.Navigation.NavigationEventArgs e)
{
ProgBar.Visibility = Visibility.Collapsed;
} private void BrowserPage_Loaded(object sender, RoutedEventArgs e)
{
if (NavigationContext.QueryString.Count > 0)
{
string url = NavigationContext.QueryString["url"];
Browser.Navigate(new Uri(url, UriKind.Absolute));
Browser.IsScriptEnabled = true;
} }
WebBrowser控件功能很强大,能够实现断网检测,启动页面,页面跳转,页面控制;网页与CS程序交互等方面。目前银行、电信自助设备使用此项功能。
private void WebMainNavigate(string strURL)
{
Object o = null;
axWebBrowser1.Navigate(strURL, ref o, ref o, ref o, ref o);
}
private void axWebBrowser1_NavigateError(object sender, AxSHDocVw.DWebBrowserEvents2_NavigateErrorEvent e)
{
Log("Erro", "检测到断网,进入打开本地页面地址:"+m_offline_main);
WebMainNavigate(m_offline_main);
//MessageBox.Show(e.uRL.ToString());
} private void ShowOfflineMain()
{
Log("Messg", "调用打开主页面地址:"+m_URL);
WebMainNavigate(m_URL);
}
Log("Messg", "启动定制浏览器!");
this.axWebBrowser1.Dock = DockStyle.None;
this.axWebBrowser1.Top = -2;
this.axWebBrowser1.Height = this.Height + 30;
this.axWebBrowser1.Left = -2;
this.axWebBrowser1.Width = this.Width + 4;
Cursor.Current = Cursors.WaitCursor;
if(!loadini())
{ Log("Erro", "请关闭程序,配置断网网页!");
MessageBox.Show("请关闭程序,配置断网网页!");
return;
}
System.Threading.Thread.Sleep(5000) ;
ShowOfflineMain();
Cursor.Current = Cursors.Default ;
{
//loadini();
Log("Messg", "启动定制浏览器!");
this.axWebBrowser1.Dock = DockStyle.None;
this.axWebBrowser1.Top = -2;
this.axWebBrowser1.Height = this.Height + 30;
this.axWebBrowser1.Left = -2;
this.axWebBrowser1.Width = this.Width + 4;
Cursor.Current = Cursors.WaitCursor;
if(!loadini())
{ Log("Erro", "请关闭程序,配置断网网页!");
MessageBox.Show("请关闭程序,配置断网网页!");
return;
}
System.Threading.Thread.Sleep(5000) ;
ShowOfflineMain();
Cursor.Current = Cursors.Default ;
}