vb.net - How to handle popup links in CefSharp -


i creating tabbed web browser using cefsharp 39.0.2. right now, if user clicks on link on website, open new window has none of original ui. example, when click on article link on google news, opens in new window, without of browsing controls have made up. looked cef.winforms.example program, , same exact thing.

is possible handle in different way? link either open in new tab, or open in new window (with controls there). have been looking through github issues, , not find (maybe not looking hard enough, because think others want well...). looked through events browser control, , not find seem handle it.

chromiumwebbrowser has lifespanhandler property. manually control popup windows in cefsharp, have implement own life span handler object implementing ilifespanhandle interface.

every time browser wants open new window, call life span handler's onbeforepopup function. here can implement desired behavior. if return false, browser pop new window. if return true, browser ignore pop action, can manually create new window, new tab, etc...

this simple example of custom life span hander. on popup request, fires event called popuprequest. can subscribe such event , create new window/tab manually. then, returns true instructs chromiumwebbrowser not create own new window. however, need implement creating new window chromiumwebbrowser on own.

public class samplelifespanhandler: ilifespanhandler {     public event action<string> popuprequest;      public bool onbeforepopup(iwebbrowser browser, string sourceurl, string targeturl, ref int x, ref int y, ref int width,         ref int height)     {         if (popuprequest != null)             popuprequest(targeturl);          return true;     }      public void onbeforeclose(iwebbrowser browser)     {      } } 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -