I've scoured the internet looking for an answer, but I must be asking the wrong question. I have a C# winforms app with an Awesomium web control. Am I able to call methods defined in the app from javascript in the page that loads? If so, how? (sample js code would be greatly appreciated). Thanks!
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- Keeping track of variable instances
- Can php detect if javascript is on or not?
The approach depends on which version of Awesomium you're using. There's been a bit of a change of how this is done in the upcoming version 1.7 (currently at 1.7 RC3) and how it was done before. Note that there's one improvement in 1.7, in that .NET methods can now return values when JS calls a method on your app. I don't believe this was possible prior to 1.7.
Here are the two methods:
test.html (used for both versions)
Version 1.7
Form1.cs
Version 1.6
Form.cs
For newer versions
Calling from JavaScript:
Inside JavaScript
To Call JavaScript
In C++: (the .NET bindings will likely be similar)
Define a callback class:
Then as you set up your WebView:
Then in your HTML/JS: