我在在WinForm中加入WebBrowser控件
this.webBrowser1.Navigate("http://www.baidu.com"); 可以 实现 用WINFROM窗体 打开网页
但是网页中 如果 出现 弹出窗体我又如何能让我的WINFROM 窗体 也能 自动 再增加一个 子窗体在里面?
而且上面 有选项卡感觉上 类似现在的 傲游的那个 方式
this.webBrowser1.Navigate("http://www.baidu.com"); 可以 实现 用WINFROM窗体 打开网页
但是网页中 如果 出现 弹出窗体我又如何能让我的WINFROM 窗体 也能 自动 再增加一个 子窗体在里面?
而且上面 有选项卡感觉上 类似现在的 傲游的那个 方式
Navigating:在WebBrowser控件导航到新文档之前发生。
NewWindow:在浏览器新窗口打开之前发生。 你可以试试。
像遨游 那样 得用分页控件吧
//一点事例
/// <summary>
/// 初始化流程图
/// </summary>
private void LoadFlowChart()
{
this.wbFlowChart.Url = new Uri(Application.StartupPath + "\\FlowChart\\CostAnalyse.html");
wbFlowChart.AllowWebBrowserDrop = false;
wbFlowChart.IsWebBrowserContextMenuEnabled = false;
wbFlowChart.WebBrowserShortcutsEnabled = false;
wbFlowChart.ObjectForScripting = this; this.wbFlowChartList.Url = new Uri(Application.StartupPath + "\\FlowChart\\left.html");
wbFlowChartList.AllowWebBrowserDrop = false;
wbFlowChartList.IsWebBrowserContextMenuEnabled = false;
wbFlowChartList.WebBrowserShortcutsEnabled = false;
wbFlowChartList.ObjectForScripting = this; this.wbFlowReport.Url = new Uri(Application.StartupPath + "\\FlowChart\\Report.html");
wbFlowReport.AllowWebBrowserDrop = false;
wbFlowReport.IsWebBrowserContextMenuEnabled = false;
wbFlowReport.WebBrowserShortcutsEnabled = false;
wbFlowReport.ObjectForScripting = this; } private void SysMangeShow()
{
this.wbFlowChart.Url = new Uri(Application.StartupPath + "\\FlowChart\\System.html");
wbFlowChart.AllowWebBrowserDrop = false;
wbFlowChart.IsWebBrowserContextMenuEnabled = false;
wbFlowChart.WebBrowserShortcutsEnabled = false;
wbFlowChart.ObjectForScripting = this;
} /// <summary
/// 流程图相应事件
/// </summary>
/// <param name="formName">回调名称</param>
[ComVisible(true)]
public void OpenForm(string formName)
{
if (string.IsNullOrEmpty(formName))
return;
switch (formName)
{
case "ConsumerDataExport": //用户级Excel导出
ConsumerDataExportShow();
break;
case "v_AdminList": //操作员管理
CostAnalyseListShow();
break;
}
}//html中调用
<td> <a href="#" onMouseOver="MM_swapImage('Image1','','Image/操作员管理-1.gif',1)" onMouseOut="MM_swapImgRestore()"><img src="Image/操作员管理.gif" name="Image1" width="80" height="73" border="0" id="Image1" onClick="window.external.OpenReportsCenter('v_AdminList','操作员管理')"/></a></td>
OpenForm后('AdminList','操作员管理')是传入Winform中OpenForm方法的参数..前者是参数值,后者显示文本..
private SHDocVw.WebBrowser_V1 Web_V1;
private void Form_Load(object sender, EventArgs e)
{
//Setup Web_V1 interface and register event handler
this.webBrowser1.Navigate(url); Web_V1 = (SHDocVw.WebBrowser_V1)this.webBrowser1.ActiveXInstance; Web_V1.NewWindow += new SHDocVw.DWebBrowserEvents_NewWindowEventHandler(Web_V1_NewWindow); } private void Web_V1_NewWindow(string URL, int Flags, string TargetFrameName, ref object PostData, string Headers, ref bool Processed)
{ Processed = true; //Stop event from being processed //Code to open in same window //this.webBrowser1.Navigate(URL); //Code to open in new window instead of same window Fomr1 Popup = new Form1(URL); Popup.Show(); }
Form form1= new Form ();
form1.FormBorderStyle = FormBorderStyle.None;
form1.MdiParent = this;
TabPage tabpage1= new TabPage();
tabControl1.Controls.Add(tabpage1);
form1.Parent = tabpage1;
form1.Show();
form1.WindowState = FormWindowState.Maximized;
参考一下上面的代码吧,变动一下就可以了