4

I have that problem whith CefSharp and js communication. This is my structure. In my MainWindow.xaml.cs I have:

chromium = new CefSharp.Wpf.ChromiumWebBrowser();
chromium.RegisterJsObject("jsInterface", new jsMapInterface());

where jsMapInterface is a public class with its methods.

In my html/js folder, I call a C# method with:

window.jsInterface.myTest();
//jsInterface.myTest();  //I have tested twice

where myTest() is a method inside jsMapInterface class but nothing happens. Where is my mistake?

Thanks in advise.

4

2 回答 2

10

在 C# 端尝试 UpperCasing,例如请注意https://github.com/cefsharp/CefSharp/wiki/Frequently-asked-questions#3-how-do-you-expose-a-net-class-toMyTest()中提到的-javascript

CefSharp 确实执行名称修改。原因是它试图鼓励在 JS 端遵循 JS 约定和在该端遵循 C# 约定。

最后从https://github.com/cefsharp/CefSharp/search?utf8=%E2%9C%93&q=BoundObject的示例代码工作

于 2015-02-12T19:51:10.870 回答
0

嗨,我想我可能迟到了......但一切看起来对我来说都很好......但也许你应该保留一个模块化 refnew jsMapInterface()以确保它不会被破坏/清理。

于 2015-02-13T16:40:26.797 回答