How to “Open in New Window” using WebBrowser contr

2019-06-22 07:52发布

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.

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??

4条回答
男人必须洒脱
2楼-- · 2019-06-22 08:09

Maybe the Source Code from this CodeProject article can help:

Extended .NET 2.0 WebBrowser Control

查看更多
我想做一个坏孩纸
3楼-- · 2019-06-22 08:13

I did this a long time ago in 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.

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.

查看更多
该账号已被封号
4楼-- · 2019-06-22 08:13

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.

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

查看更多
狗以群分
5楼-- · 2019-06-22 08:24

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

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

查看更多
登录 后发表回答