Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to disable open page in new window? #688

Closed
songjinxi opened this issue Dec 14, 2014 · 3 comments
Closed

How to disable open page in new window? #688

songjinxi opened this issue Dec 14, 2014 · 3 comments

Comments

@songjinxi
Copy link

How to disable open page in new window? I want to open a new page in self

@amaitland
Copy link
Member

#600 (comment)

@amaitland
Copy link
Member

Closing as this is a duplicate. See #600

@MarcAlx
Copy link

MarcAlx commented Jun 12, 2019

As the api has changed since the last answer has been posted, here's how to acheive that

Implement ILifeSpanHandler in a new class.

With the following implementation of OnBeforePopup

public bool 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)
        {
            browser.MainFrame.LoadUrl(targetUrl);
            newBrowser = null;
            return true;
        }

Then instantiate your implementation and set the LifeSpanHandler property of your browser with it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants