Welcome Guest Search | Active Topics | Sign In | Register

something similar to WebView2 - WebMessageReceived Options
Dietrich
Posted: Thursday, July 7, 2022 10:22:57 AM
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
eo_support
Posted: Thursday, July 7, 2022 5:28:42 PM
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.html

Please 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!
Dietrich
Posted: Monday, July 11, 2022 6:03:06 AM
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...
eo_support
Posted: Monday, July 11, 2022 11:09:20 AM
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.html

Thanks!
Dietrich
Posted: Monday, July 11, 2022 11:59:12 AM
Rank: Newbie
Groups: Member

Joined: 7/7/2022
Posts: 3
That was the missing part for me! Thanks a lot!!
eo_support
Posted: Monday, July 11, 2022 1:19:12 PM
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.


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.