PowerBuilder PB2022R3 3356, Windows 10 and Window 11
Hi,
I want to execute jscript code with a window. I tried to use the webrowser (WebView2) EvaluateJavaScriptSync() function:
integer li_rc
string ls_Result, ls_ErrorMsg
webbrowser lwb_Object
OpenUserObject( ref lwb_Object )
lwb_Object.Visible = FALSE
// without the MessageBox EvaluateJavaScriptSync(...) returns:
// -2 Failed to initialize the control and obtain the WebBrowser object. The WebView2 is invalid.
// with the MessageBox EvaluateJavaScriptSync(...) returns:
// 1 und ls_Result is the expected »{"type":"string","value":"lv PowerBuilder"}«
//MessageBox( "", "Continue?" ) // then it works
li_rc = lwb_Object.EvaluateJavaScriptSync( "'lv PowerBuilder';", ref ls_Result, ref ls_ErrorMsg )
CloseUserObject( lwb_Object )
destroy lwb_Object
Why is the call to MessageBox necessary to successfully execute EvaluateJavaScriptSync()? Is there a way to avoid the call to MessageBox or what can I do instead of calling it?
Of course, I can place an invisible webbrowser control on the window. But what is the effect of the call to MessageBox?
Thanks in advence,
Bernhard
I take an instance wb, open it in window.open() and close itin window.close().
I was only wondering why me first approach did not work.
Regards Bernhard
If Kai's suggestion does not work, then please open a support ticket for the OpenUserObject approach
Regards ... Chris