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

OnBeforePopup return false but new windows open [a target="_blank"]? #348

Closed
gap032 opened this issue May 5, 2014 · 4 comments
Closed
Labels

Comments

@gap032
Copy link

gap032 commented May 5, 2014

HI,
i've implemented cefsharp 1.25.0 with WPF (it must support .NET3.5), handle filedownloads and opening external links with IE like below:

bool ILifeSpanHandler.OnBeforePopup(CefSharp.IWebBrowser browser, string url, ref int x, ref int y, ref int width, ref int height)
{
            if (url.Contains(home_url))
            {
                  return false;
            }else{
                Process.Start("IExplore.exe", url);
                return true;
            }
}

bool IRequestHandler.GetDownloadHandler(IWebBrowser browser, string mimeType, string fileName, long contentLength, ref IDownloadHandler handler)
        {
            handler = new DownloadHandler(fileName);
            return true;
        }

in DownloadHandler(string fileName) with savefiledialog i've got messagebox:

...
Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() =>
                {
                    MessageBoxResult result = MessageBox.Show(Application.Current.MainWindow, msg, "Message1", MessageBoxButton.YesNo, MessageBoxImage.Question);
                    if (result == MessageBoxResult.No)
                    {
                        _templocation = true;
                    }
                }));
...

to handle downloading file to temp location. When download link has target="_self" attribute everything works ok, but when it has target="_blank" a new blank window apperars on top of messagebox.

How can I close from code that new blank window or force to now show it?

@gap032 gap032 changed the title OnBeforePopup return false but new windows open [a target="blank"]? OnBeforePopup return false but new windows open [a target="_blank"]? May 5, 2014
@gap032
Copy link
Author

gap032 commented May 5, 2014

OK, I found workaround:
#198

@jornh jornh added the question label May 5, 2014
@jornh
Copy link
Contributor

jornh commented May 5, 2014

As I read the CEF API doc for OnBeforePopup() you should return true (not false) if you wan't to suppress the popup.

Anyway since you found another workaround and this sounds more like a question than a bug I will close this issue. I hope that's OK 😄

@jornh jornh closed this as completed May 5, 2014
@rsanjay23
Copy link

how to download a file to my system...please suggest me

@amaitland
Copy link
Member

@rsanjay23 Rather than comment on a closed thread, please post a new question or post on the CefSharp Google Group. Thanks

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

No branches or pull requests

4 participants