如何从CefSharp 3在本机浏览器中打开链接 [英] How to open a link in a native browser from CefSharp 3

查看:121
本文介绍了如何从CefSharp 3在本机浏览器中打开链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在CefSharp 3的本机浏览器中打开链接。我需要在CefSharp 3的Chrome浏览器中运行整个应用程序,除了表格。当我单击表单的链接按钮(例如-注册按钮。它具有指向注册表单的链接)时,我需要在本机浏览器(例如Internet Explorer)中打开此链接。

I have a requirement to open a link in a native browser from CefSharp 3. I need to run the whole application in CefSharp 3's chromium browser except a form. when I click the form's link button (Eg - Register button. It has a link to the registration form) I need to open this link in the native browser (Eg - Internet Explorer).

我们可以在CefSharp中实现吗?

Can we achieve this in CefSharp?

我搜索了Google以及堆栈溢出。

I searched the google as well as stack overflow. But unable to find a solution.

推荐答案

正如holroy所建议的,我已经在CefSharp的RequestHandler类中实现了OnBeforeNavigation()方法。例子包。

As suggested by holroy I have implemented the OnBeforeNavigation() method in the RequestHandler class in CefSharp.Example package.

这是工作代码,

 bool IRequestHandler.OnBeforeBrowse(IWebBrowser browserControl,
 IBrowser browser, IFrame frame, IRequest request, bool isRedirect)
         {
             // If the url is Google open Default browser
             if (request.Url.Equals("http://google.com/"))
             {
                 // Open Google in Default browser 
                 System.Diagnostics.Process.Start("http://google.com/");
                 return true;
             }else
             {
                 // Url except Google open in CefSharp's Chromium browser
                 return false;
             }
         }

我希望这会在将来对其他人有所帮助。

I hope this will help to some one else in future.

谢谢,

这篇关于如何从CefSharp 3在本机浏览器中打开链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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