Web浏览器控制新的Window问题并支持选项卡 [英] Web Browser control new Window issue and support for Tabs

查看:78
本文介绍了Web浏览器控制新的Window问题并支持选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近使用WPF的网络浏览器,发现有一种方法可以知道是否会打开新窗口.

Recently working with WPF's web browser and found out that there is know way to know if a new window will open.

如果链接存在目标",则为目标".如下所示的属性< a href ="< link>" target =空白" >清除这里</a>

If for a link there is a "Target" Attribute like below <a href="<link>" target="blank">Clear Here</a>

然后,浏览控件将在新的浏览器中打开链接,并且不会提供任何事件或方式来避免这种情况.

如果用户尝试通过javascript打开新窗口,也会发生这种情况

函数openWin()     {  win = window.open("< link>"));  我们可以使用Windows窗体Web浏览器控件来实现此目的,但即使这样也不能完全证明,因为它不能让您知道在新窗口中将打开哪个链接.

This can we achieved with windows form Web Browser control but even that is not full proof as it does not give you any way to know which link will be opened in new windows.

是否有某种方法可以实现这一目标,并且还知道正在打开哪个链接.

Is there some way to achieve this and also know which link is being opened.

推荐答案

如果要防止打开新窗口浏览器,请在以下主题中参考我的回答: https://social.msdn.microsoft.com/Forums/zh-CN/2ea05f5d-3c9d-4f45-a0b9-04bb5fafed77/webbrowser?forum=wpf

If you want to prevent a new window browser from being opened then please refer to my answer in the following thread: https://social.msdn.microsoft.com/Forums/en-US/2ea05f5d-3c9d-4f45-a0b9-04bb5fafed77/webbrowser?forum=wpf

您可以添加对COM库"Microsoft Internet Controls"的引用.并按照上述线程中的建议处理IWebBrowser2接口的NewWindow事件.

You could add a reference to the COM Library "Microsoft Internet Controls" and handle the NewWindow event of the IWebBrowser2 interface as suggested in the above thread.

希望有帮助.

请记住,通过将有用的帖子标记为答案来关闭话题,然后在遇到新问题时开始新话题.请不要在同一线程中问几个问题.

Please remember to close your threads by marking helpful posts as answer and then start a new thread if you have a new question. Please don't ask several questions in the same thread.


这篇关于Web浏览器控制新的Window问题并支持选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆