MBS; WebView2ControlMBS; ExecuteScriptSync; Win10;

I have put some calls in a row for ExecuteScriptSync with “console.log(‘adding CSS’)”.

The function takes about 20 seconds to return to the debugger.

ErrCode = -1; result is blank as expected.

Is a return from JS needed?

Thanks in advance!

I could solve this by using ExecuteScript with counted up variable names…

We have a 60 second timeout, I think.

So if the JavaScript doesn’t return quickly, the plugin will return with no result and error code = -1.

Thanks a lot for the info!

So, return needed.

I can’t get the result immediately back; “1 + 2” nor “(() => { return {Test:1}})()” does work.

Have to switch back to ExecuteScript until sync function does work.

I just tried our example and put this in a button’s action event:

Sub Action() Handles Action
  Dim error As Integer
  Dim v As Variant = web.ExecuteScriptSync("1+2", error)
  MsgBox Str(Error)+": "+v.StringValue
End Sub

and this works fine here. Not sure what’s different for you.
Anyway, async is usually better. I prefer sync only for quick things like querying a property.

The problem is, that ExecuteScriptSync does not work without begin triggered by an event.

I use the event NavigationsCompleted to fill up the empty HTML page with CSS/JS.
This works seemless with ExecuteScript.

Then, when I instead use ExecuteScriptSync, the timeout is used, regardless what’s being returned.

Thanks a lot!