简体   繁体   中英

How to refresh a specific frame in CEFSharp

I have a Winforms Application using .NET 4.7.2 and CEFSharp 84.4.10.

I have a website loaded into the CEF browser that has a frameset and I want to have a menu item in the context menu that will reload a specific frame.

I have the menu item happening and in the event handler I tried the following two approaches but they both reload the entire browser, not just the frame.

How can I reload just the frame?

Thank you for your time.

    bool IContextMenuHandler.OnContextMenuCommand(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IContextMenuParams parameters, CefMenuCommand commandId, CefEventFlags eventFlags)
    {
        switch ((int)commandId)
        {
            ...

            case RefreshContentFrame:
                frame.Browser.Reload(true);
                break;
            ...
        }

        return false;
    }

and

    bool IContextMenuHandler.OnContextMenuCommand(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IContextMenuParams parameters, CefMenuCommand commandId, CefEventFlags eventFlags)
    {
        switch ((int)commandId)
        {
            ...

            case RefreshContentFrame:
                var myFrame = browser.GetFrame("MyFrame");
                if (myFrame != null)
                {
                    myFrame.Browser.Reload(true);
                }
                break;
            ...
        }

        return false;
    }

Thanks to @amaitland for clarifying that reloading a single frame is not currently supported. I went with the solution doing it via JS API.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM