1. Dexter Madrinan
  2. PowerBuilder
  3. Wednesday, 11 January 2023 03:24 AM UTC

Hi Guys,

In the Window PostOpen event, Javascript functions are not recognized/found when EvaluateJavascriptAsync() is invoked on the Webbrowser control. Also, dynamically rendered HTML has the same issue.

Code:

string ls_json 

int li_return 
ls_json = wf_get_archive_hist(as_key)
if gf_isstringnull(ls_json,'')<>'' then
ls_js="SetDnoteArchiveHist('"+ls_json+"');"
li_return = wb_1.EvaluateJavascriptAsync( ls_js)
yield()
end if

Above code is invoke at window postevent ue_postopen() .

 

Version: PB 2022

Your advise is highly appreciated.

Best Regards,

 

Dexter P. Madrinan

Dexter Madrinan Accepted Answer Pending Moderation
  1. Friday, 13 January 2023 04:27 AM UTC
  2. PowerBuilder
  3. # 1

Screenshot

Attachments (1)
Comment
There are no comments made yet.
Dexter Madrinan Accepted Answer Pending Moderation
  1. Friday, 13 January 2023 02:52 AM UTC
  2. PowerBuilder
  3. # 2

Hi Miguel,

 

In this, "Just curiosity: What happens if you use EvaluateJavascriptSync() instead of EvaluateJavascriptAsync() ?" same also happens. Webbrowser control is not as stable as expected will see in their next release.

Thank you.

Comment
  1. Miguel Leeuwe
  2. Friday, 13 January 2023 04:20 AM UTC
Hi,

https://docs.appeon.com/pb2019r3/powerscript_reference/ch02s04s156.html and

https://docs.appeon.com/pb2019r3/powerscript_reference/ch02s04s155.html

Async triggers an event called EvaluateJavascriptFinished() and allows Alert dialogs to be used in the js.

Sync supposedly does not trigger that event? Not sure. Does NOT allow any dialogs.



I agree that things aren't very stable. I can't wait for pb2022 R2 when the CEF browser is going to be replaced with WebView2 !

regards
  1. Helpful
  1. Dexter Madrinan
  2. Friday, 13 January 2023 04:26 AM UTC
The event is triggered and throws error that is not recognized/defined.



See screenshot below..
  1. Helpful
  1. Miguel Leeuwe
  2. Friday, 13 January 2023 05:57 AM UTC
hmmmm ... Maybe you should create a ticket on the bug site for this. https://www.appeon.com/standardsupport/newbug They can probably help you better.

regards
  1. Helpful 1
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Wednesday, 11 January 2023 06:02 AM UTC
  2. PowerBuilder
  3. # 3

Hi,

Please see https://www.appeon.com/standardsupport/search/view?id=8663 and https://www.appeon.com/standardsupport/search/view?id=7803 

The EvaluateJavascript(Async)() functions aren't that stable in my opinion. What is always successful, is to NOT use dynamic JS, but simply call a JS function that you have in your HTML. In your case though, that might not be an easy solution.

I found that having some specific code in the Open() event of the application object improved things significantly:

Do you have a similar code like this (see code block below) in the Open event of your application object?
(w_wbrowser_dummy is a small invisible window that prevents a bug of the application blowing up on windows server 2012, when exiting the application.)

I haven't tried it myself, but this could be an alternative for the webbrowser control. (also based on the chrome engine):
https://community.appeon.com/index.php/qna/q-a/save-pdf-from-webbrowser-control-header-footer/oldest
https://drive.google.com/file/d/1BLuFYKJl00-okqM3LHFHJB60jPUfFub8/view

-------------------------
// v3, mjl, 18/06/21: seems to be a necessary setting for CEF webbrowser control:
int li_ret
string ls_ret
li_ret = WebBrowserGet("UserAgent", ref ls_ret)
if ls_ret = "" then
	li_ret = WebBrowserSet("UserAgent", "AppeonWebBrowser")
	if li_ret <> 1 then
		Messagebox("Information", "Error setting the UserAgent for the WebBrowser", information!)
	end if
end if

// v4, mjl, 05/07/21: avoid an existing Appeon bug of blowing up when using the webbrowser control on Windows Server 2012 R2:
open(w_wbrowser_dummy)
close(w_wbrowser_dummy)

string ls_docFolder
n_filesys lnf
ls_docFolder = lnf.of_getfolderpath(CSIDL_PERSONAL)

li_ret = WebBrowserSet("DownloadPath", ls_docFolder)
if li_ret <> 1 then
	Messagebox("Information", "Error setting the DownloadPath for the WebBrowser", information!)
end if

li_ret = WebBrowserSet("allow-file-access-from-files", "true")
if li_ret <> 1 then
	Messagebox("Information", "Error setting the FileAccess for the WebBrowser", information!)
end if
Comment
  1. Dexter Madrinan
  2. Wednesday, 11 January 2023 07:44 AM UTC
That time the error comes up. I reboot my system. Ok let me try to put that code and see. Thanks
  1. Helpful
  1. Miguel Leeuwe
  2. Wednesday, 11 January 2023 07:49 AM UTC
YW, I'm not an expert on this, but just commenting on what I experienced with PB2019 (not 2022 !). Maybe it's a good idea too to post this on https://www.appeon.com/standardsupport/newbug .

Hope you figure it out.

As a last idea, you could define the JS as a function within the HTML files. Since your html is dynamic, you would have to edit that html from code, which is more of a pain and then also you would have your JS exposed to anyone who can read the files, so not as good as your initial approach.
  1. Helpful
  1. Dexter Madrinan
  2. Wednesday, 11 January 2023 09:50 AM UTC
Actually, I load my JS file as a separate file on this but still both HTML & JS are exposed to users.
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.