0

I would like to manage the dialogbox generated by the webview2. Example : Confirm a command or download.

I saw that maybe it was the CoreWebView2.ScriptDialogOpening event. But I don't know how to use it. So, have you an example because I don't find this Event in WPF

Thanks a lot

1 Answers1

1

The WebView2 control doesn't expose the same APIs that CoreWebView2 does. Instead the WebView2 exposes some basic APIs that CoreWebView2 does and for the rest it exposes its CoreWebView2 object via its CoreWebView2 property. This property is non-null after the WebView2 control has been initialized by awaiting the EnsureCoreWebView2Async method or the CoreWebView2Ready event is raised. You can read more about the WebView2 control initializing the CoreWebView2 in our docs.

So you can find the event on webView2.CoreWebView2.ScriptDialogOpening after the CoreWebView2 is initialized

David Risney
  • 3,886
  • 15
  • 16
  • Is it possible to detect dialogbox openning and valide the action button with a addEventListener.? – François HEBERT Jan 30 '21 at 12:54
  • When I do : functionString = String.Format("document.getElementById('actionUpdateSoftwareVersionSubmit').click()") result = Await webview_Cockpit.CoreWebView2.ExecuteScriptAsync(functionString) The htm page return a dialogbox. Here is the html code. So I would want Confirm the command by my application – François HEBERT Jan 30 '21 at 14:22
  • I found the solution here :https://stackoverflow.com/questions/31814031/automating-javascript-confirmation-box – François HEBERT Jan 30 '21 at 16:13