My setup is really simple, in C# (WPF) I have a WebView, that loads my HTML page.
Now I want to have a two way communication between the two.
Calling C# from Javascript works totally fine for me, using RegisterJsObject
.
Now I try to execute Javascript from C#, using ExecuteScript
.
As long as I only use plain Javascript, such as
ExecuteScript("document.getElementById('test').innerHTML='test'")</code>
it works perfectly fine.
But when I try to access functions I created in Javascript, it fails to execute them.
Javascript:
function test(param) {
alert(param);
}
C#:
webView.ExecuteScript("test('123')");
I am not sure, what my actual problem was.
I got it to work by starting from scratch again, starting with basic calls, then getting closer to the actual code I want to execute, and now it somehow works.