-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can you retreive the result of a JS callback function called by a host object? #515
Comments
Personally I suggest not using host object. Instead, use a helper JavaScript to do the communication. |
I don't think this is currently supported, so I added a scenario to our backlog. Thanks! |
@ysc3839 , I'm trying to use WebView2 to get a JWT after login. I'm currently grabbing the html content, is there an easier way? |
This issue makes it clear that you can't obtain the result of invoking a JavaScript callback set on a native host object from native code via For what it's worth, it's possible to hack around this limitation using
|
js get result from vb6(host exe) |
I've been experimenting with the AddHostObjectToScript functionality, and am most intrigued by the ability to pass callback functions back and forth between the host application and the WebView2 instance. I've had success in invoking a callback function as defined in JavaScript (such as showing a page alert), but it is not clear to me how to retrieve the result of the callback function after it has finished its asynchronous execution.
Here is some mock JavaScript and C++ pseudo code which may give a bit more insight into the situation. I'm developing my application in another language (not C++) so I may have made some error in the implementation below, but I think it should get the point across.
It appears from my tests that the IDispatch interface for the callback function does not alter the data pointed to by the
pVarResult
parameter. My hope was that it would return a new IDispatch object representing a promise, where I could invoke athen
method and give it a host object to be called once the result was available.I suppose I could rewrite the JavaScript to explicitly invoke a host object instead of returning a value, but that seems non-ideal. Is there there a way to retrieve the return value, or, if not, is there planned to be a way to retrieve it?
AB#29826508
The text was updated successfully, but these errors were encountered: