|
Rank: Newbie Groups: Member
Joined: 7/7/2022 Posts: 3
|
With WebView2 you have the possibility to react on a message: ... webView.WebMessageReceived += WebView_WebMessageReceived; ... private void WebView_WebMessageReceived(object sender, CoreWebView2WebMessageReceivedEventArgs e) { if (!string.IsNullOrEmpty(e.WebMessageAsJson)) { dynamic message = JsonConvert.DeserializeObject(e.WebMessageAsJson); if (message.action == "setTitle") { Title = $"{originalTitle} {message.value}"; }
if (message.action == "revertTitle") { Title = originalTitle; } } }
Is there a similar possibility with EOWebView / EOWinForm
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
Hi, There is no built-in support for this but it can be implemented with additional coding. The basic steps are: 1. Handling the message event in JavaScript; 2. Inside your JavaScript code that handles the message event, you can call back to C# side. See here for more details on this feature: https://www.essentialobjects.com/doc/webbrowser/advanced/jsext.htmlPlease keep in mind that inside your C# side handler you will not be able to call back to the JavaScript engine again (to avoid JavaScript engine re-entering issue). So you won't be able to pass "message" object directly to C# side and then check "message.action", instead you would need to pass message.action as an argument by itself. In another word, all JavaScript evaluation needs to be done before you call into C# side. Please feel free to let us know if you have any more questions. Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 7/7/2022 Posts: 3
|
Thank you for the answer. Unfortunately I do not have the JavaScript-part under control. We use the EOWebView as a plugin within an ERP-System to visualize DMS-documents in the application-context. For example the documents of the customer, which is shown. We use the DocuWare SDK to build the correct URL and pass ist to the EOWebView (see here: https://developer.docuware.com/URL_Integration/examples/viewer.html). At the first look everything works fine, but the DocuWare-Web-UI has some "special features" which are only supported in a native (Edge, Chrome, Firefox-)Browser-Window. And so I am searching workarounds...
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
Hi, You do not have to have full control over the page's JavaScript code. You can simply use WebView.JSInitCode to inject additional JavaScript code into the page. See here: https://www.essentialobjects.com/doc/eo.webbrowser.webview.jsinitcode.htmlThanks!
|
|
Rank: Newbie Groups: Member
Joined: 7/7/2022 Posts: 3
|
That was the missing part for me! Thanks a lot!!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
You are very welcome. Please feel free to let us know if you have any more questions.
|
|