Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

disallow disable open page in new window does not work #3403

Closed
imcool opened this issue Feb 12, 2021 · 0 comments
Closed

disallow disable open page in new window does not work #3403

imcool opened this issue Feb 12, 2021 · 0 comments

Comments

@imcool
Copy link

imcool commented Feb 12, 2021

cefsharp opening two windows while navigating on google page but i want to open in one window
I have tried a lot but couldnt make it work :(. I want to have this second window open in same main window rather than new window.

I tried following but no luck, maybe i did something wrong as I am not good at coding :(

#600

#688

https://www.codeproject.com/Articles/1194609/Capturing-a-pop-up-window-using-LifeSpanHandler-an

can you please help me find solution so it opens in only Window no matter what button you click on any webpage

`
using CefSharp;
using CefSharp.WinForms;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;
using System.Runtime.InteropServices;
using System.Diagnostics;
using Microsoft.Win32;

namespace Nysus
{

public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

    ChromiumWebBrowser chrome;
    private void Form1_Load(object sender, EventArgs e)
    {
        CefSettings settings = new CefSettings();
        //Initialize
        Cef.EnableHighDPISupport();
        Cef.Initialize(settings);
        chrome = new ChromiumWebBrowser("http://www.google.com");
        this.pContainer.Controls.Add(chrome);
        chrome.Dock = DockStyle.Fill;
      
        this.FormBorderStyle = FormBorderStyle.None;
        this.WindowState = FormWindowState.Maximized;
        if (chrome.CanGoForward)
            chrome.Forward();
        if (chrome.CanGoBack)
            chrome.Back();
    }
   
    private void Form1_FormClosing_1(object sender, FormClosingEventArgs e)
    {
        Cef.Shutdown();
    }

    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;
    }

}

}
`

https://i.stack.imgur.com/QWvRx.png

see in the image it opens two different Window when I click privacy or terms etc on google, I want it to open in same Window

@cefsharp cefsharp locked and limited conversation to collaborators Feb 12, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants