S
S
Stepan Davashenevquestion2020-04-18 11:48:33
C++ / C#
Stepan Davashenevquestion, 2020-04-18 11:48:33

How to add JS execution to CefSharp?

like adding a new method

CefSharpSettings.LegacyJavascriptBindingEnabled = true;
CefSharpSettings.WcfEnabled = true;
chromeBrowser.JavascriptObjectRepository.Register("DevForm_class", new DevForm_class(chromeBrowser, this), isAsync: false, options: BindingOptions.DefaultBinder);

added here
public Form1()
// после 
InitializeComponent();
InitializeChromium();

but i get an error

System.Exception: The ChromiumWebBrowser instance creates the underlying Chromium Embedded Framework (CEF) browser instance in an async fashion. The undelying CefBrowser instance is not yet initialized. Use the IsBrowserInitializedChanged event and check the IsBrowserInitialized property to determine when the browser has been initialized.

I think the answer is in a highlighted block,
but I don’t know how to overcome it (
adding JS with the old method doesn’t work at all

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stepan Davashchenevquestion, 2020-04-20
@nezabor

it was not about the babin - it would have been about the wires
, this was superfluous ▼

private void Form1_Load(object sender, EventArgs e)
        {
            chromeBrowser.ShowDevTools(); // этому здесь не место
        }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question