Reputation: 23
I just developed an application like a web browser with the use of Cefsharp library in windows form application. My browser has got several tabs, but whenever user clicks on 'a link tags' with the property of _blank the application opens a new link in a separated window although I want to open links in a new tab in tab control instead.
what I used for my application:
C# windows form application
ChromiumWebBrowser class from Cefsharp library
I would be pleased if anyone can help.
Upvotes: 0
Views: 1355
Reputation: 23
I've just looked through the documentation and found out the issue.
Here's what I've done for my problem:
public class LifespanHandler : ILifeSpanHandler
{
bool ILifeSpanHandler.OnBeforePopup(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, string targetUrl, string targetFrameName, WindowOpenDisposition targetDisposition, bool userGesture, IPopupFeatures popupFeatures, IWindowInfo windowInfo, IBrowserSettings browserSettings, ref bool noJavascriptAccess, out IWebBrowser newBrowser)
{
Program.Form.Invoke(new Action(() => Program.Form.newPage(targetUrl)));
//browser.MainFrame.LoadUrl(targetUrl);
newBrowser = null;
return true;
}
}
Hope this is useful for you. :)
Upvotes: 0