3

我需要知道如何在 cefsharp 上更改 web 视图的位置时设置事件以及如何防止不重定向到其他 url

        BrowserSettings browserSettings = new BrowserSettings();
        browserSettings.FileAccessFromFileUrlsAllowed = true;
        browserSettings.UniversalAccessFromFileUrlsAllowed = true;
        browserSettings.TextAreaResizeDisabled = true;
        WebView web_view;
        web_view = new WebView("http://google.com", browserSettings);
        web_view.LocationChanged += ??`enter code here`
        web_view.Dock = DockStyle.Fill;
        this.Controls.Add(web_view);
4

1 回答 1

4

我认为您需要提供IRequestHandler接口的实现。请参阅https://github.com/cefsharp/CefSharp/blob/CefSharp1/CefSharp.Example/ExamplePresenter.cs#L263 如果您返回true,您将阻止导航。

LocationChanged您所说的事件与 CefSharp 网络导航无关。如果您在 Google 上搜索“LocationChanged 事件”,它可能会在您的脸上留下微笑 :)

于 2014-02-17T01:38:05.503 回答