Cefsharp: How to intercept every link clicked inside a ChromiumWebBrowser instance?

Created on 2 Nov 2014  路  4Comments  路  Source: cefsharp/CefSharp

Is this currently possible? If so, what's the event for that or does this require a different kind of implementation? Sorry to use the issue system as a "support forum" but I couldn't find anything related to this and I'm not sure if it's even possible.

The idea behind this is to open the default system browser for any link that not belongs to a certain domain instead of using the application's web view instance.

Can this be done?

question

Most helpful comment

It seems that the method can't intercept invalid url such as test. It just goes to a blank page, what is the best practice for this scenario?

All 4 comments

IRequestHandler.OnBeforeBrowse() is probably your friend for this ... see a bit of discussion in https://github.com/cefsharp/CefSharp/pull/354 where it got introduced or this search across code and issues https://github.com/cefsharp/CefSharp/search?q=OnBeforeBrowse&type=Code

That's exactly it, thanks.

If it's not a problem, I'll leave this issue opened for a couple of days until I find the time to implement what I need; just in case I encounter some issues along the way.

It seems that the method can't intercept invalid url such as test. It just goes to a blank page, what is the best practice for this scenario?

You'll most likely have to hook event EventHandler<LoadErrorEventArgs> LoadError;

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Spocher picture Spocher  路  4Comments

zhuangpearl picture zhuangpearl  路  4Comments

looselive picture looselive  路  4Comments

richmondwang picture richmondwang  路  6Comments

amaitland picture amaitland  路  4Comments