如何使用WebBrowser控件“在新窗口中打开”?

时间:2021-07-09 20:44:47

When you use the WebBrowser control in .NET you can "embed" an instance of IE in your application, essentially making your own IE-based Web Browser.

当你在。net中使用WebBrowser控件时,你可以在你的应用程序中“嵌入”一个IE实例,本质上就是创建你自己的基于ibase的Web浏览器。

Does anyone know how to make any new windows created (like when the user selects "Open in New Window" from the context menu) open up in another Window of Your Web Browser Application, instead of the computers default browser??

有谁知道如何在Web浏览器应用程序的另一个窗口(比如当用户从上下文菜单中选择“在新窗口中打开”)中打开,而不是在计算机的默认浏览器中?

4 个解决方案

#1


4  

Maybe the Source Code from this CodeProject article can help:

也许这篇CodeProject文章的源代码可以帮助您:

Extended .NET 2.0 WebBrowser Control

扩展的。net 2.0 web浏览器控件

#2


1  

I did this a long time ago in VB.

我很久以前在VB中做过这个。

From what I remember, when a NewWindow2 event was fired by the control, we would cancel the original request and open a separate VB form that contained another instance of the WebBrowser control pointed at the requested URL.

我记得,当控件触发NewWindow2事件时,我们将取消原始请求,并打开一个单独的VB表单,其中包含指向所请求URL的WebBrowser控件的另一个实例。

I did a quick google search and it seems like maybe this event isn't as easy to access in .Net. Take a look here for a possible solution.

我做了一个快速的谷歌搜索,似乎这个事件在。net中不那么容易访问。看看这里有没有可能的解决办法。

#3


0  

There's a code sample here that contains code for adding the NewWindow2 event to the WebBrowser control. It sure would be nice if they added this event to the WebBrowser control itself.

这里有一个代码示例,其中包含将NewWindow2事件添加到WebBrowser控件的代码。如果他们将这个事件添加到WebBrowser控件本身,那就太好了。

http://zerosandtheone.com/media/p/277.aspx

http://zerosandtheone.com/media/p/277.aspx

#4


0  

This site has the best solution I've found if you're using the .net version of the webbrowser control

如果你正在使用。net版本的webbrowser控件,这个网站有我找到的最好的解决方案

http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/f497f8a5-dac8-48cb-9fce-7936c9389f09

http://social.msdn.microsoft.com/forums/en - us/winforms/thread/f497f8a5 dac8 - 48 - cb - 9 - fce考试- 7936 c9389f09

#1


4  

Maybe the Source Code from this CodeProject article can help:

也许这篇CodeProject文章的源代码可以帮助您:

Extended .NET 2.0 WebBrowser Control

扩展的。net 2.0 web浏览器控件

#2


1  

I did this a long time ago in VB.

我很久以前在VB中做过这个。

From what I remember, when a NewWindow2 event was fired by the control, we would cancel the original request and open a separate VB form that contained another instance of the WebBrowser control pointed at the requested URL.

我记得,当控件触发NewWindow2事件时,我们将取消原始请求,并打开一个单独的VB表单,其中包含指向所请求URL的WebBrowser控件的另一个实例。

I did a quick google search and it seems like maybe this event isn't as easy to access in .Net. Take a look here for a possible solution.

我做了一个快速的谷歌搜索,似乎这个事件在。net中不那么容易访问。看看这里有没有可能的解决办法。

#3


0  

There's a code sample here that contains code for adding the NewWindow2 event to the WebBrowser control. It sure would be nice if they added this event to the WebBrowser control itself.

这里有一个代码示例,其中包含将NewWindow2事件添加到WebBrowser控件的代码。如果他们将这个事件添加到WebBrowser控件本身,那就太好了。

http://zerosandtheone.com/media/p/277.aspx

http://zerosandtheone.com/media/p/277.aspx

#4


0  

This site has the best solution I've found if you're using the .net version of the webbrowser control

如果你正在使用。net版本的webbrowser控件,这个网站有我找到的最好的解决方案

http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/f497f8a5-dac8-48cb-9fce-7936c9389f09

http://social.msdn.microsoft.com/forums/en - us/winforms/thread/f497f8a5 dac8 - 48 - cb - 9 - fce考试- 7936 c9389f09