ExecuteJavaScript / ExecuteJavaScriptSync and executeInXojo() / executeInXojoSync()

The documentation around these methods seems to imply that inside the HTMLViewer, it is only possible to successfully call executeInXojo() / executeInXojoSync() from inside a method that has itself been launched by the Xojo side via executeInXojo() / executeInXojoSync(). By successful I mean such that a JavaScriptRequest event occurs on the Xojo side.

Now a little experimentation here (Catalina and 2023r1.1) shows that at least under macOS this limitation does not exist. I can load a page into an HTMLViewer and have it cause a JavaScriptRequest event.

Since I would find this feature very useful, could someone at Xojo confirm that the implied limitation does not, in fact, exist for any desktop platform, and have the documentation updated accordingly?

That limitation does not exist. You can use those functions anytime after the HTMLViewer has loaded content.

1 Like

I can confirm for Windows and MacOS that this limitation does not exist.
We use these methods extensively.
Maybe you can tell us which part in the documentation makes you think this limitation exists?

See the doc for the DesktopHTMLViewer, JavaScriptRequest event:

JavaScriptRequest (method As String, parameters() As Variant) As String

Called when a JavaScript executed via ExecuteJavaScript or ExecuteJavaScriptSync calls ExecuteInXojo or ExecuteInXojoSync.

A JavaScript executed via ExecuteJavaScript or ExecuteJavaScriptSync can call executeInXojo() or executeInXojoSync() to pass data back to the HTMLViewer via this event.

That strongly implies that the use of this event is limited just to javascript launched from the Xojo side. The notes at the end of the DesktopHTMLViewer say more or less the same.

Thanks for that. I didn’t want to find that it happened to work by chance and was not supported.

I put the “executeinxojo” directly in the initial html text I load with LoadPage from the htmlviewer and it works fine
you don’t need to use it only with executejavascript method.

Yes, I’ve had no problems with it running under macOS and Win-10 in a VM. I’ll be able to test early next week with Win-11 on real hardware.

However, @Anthony_G_Cyphers and @Jean-Yves_Pochez , under Linux (Linux Mint 21.1 Vera) using those methods gives rise to a script error. I put this down to the fact that executeInXojo() and executeInXojoSync() are missing and I don’t appear to have a choice of renderer for the HTMLViewer. I can put in a dummy version of those functions, which removes the script error (although the app then doesn’t work, of course).

I just tried my project under ubuntu and it seems to work fine
I have a font problem (but who doesn’t with linux ?)
but the executexojo seems to execute just fine there.

Odd. I just tried it also under Mint 20.3 Una and it failed there too. I’ll have a careful check to verify I don’t have some odd Linux dependency, otherwise I’ll file an Issue. Thanks for the feedback.

Which version of Xojo are you using?

xojo 2023r11

I tried 2022r3.2 and r4.1, same thing happens. Here is what try/catch around my javascript call to executeInXojoSync gives here:

You see my desktop, Linux running in a VM, and the result of clicking either the Test button on the web page or the Execute button from the Xojo side. This all works under macOS and Win-10.

Issue 73196.

your test project works under ubuntu 22 for me. no error.


If I download the Linux version of the IDE into my Mint VM, and run the testbed app under that, it works. Further, I can build an executable under macOS and it runs OK under Mint.

So, the failing combination seems tto be when testing remotely with a macOS IDE into a Mint VM.

Ah ! I did not try that. I compiled the linux executable and ran it.
I did not try remote debug the linux from macos xojo…

I conclude that there is a list of modules to send to the remote end when remote debugging, and this list is missing an item for macOS IDE → remote Linux client.

Much testing done. I downloaded the IDE into my Linux Mint VMs and found I can’t run under the IDE debugger without finding that executeInXojo is apparently missing. But I can build the apps and run them OK from the desktop or from within /usr/local/bin provided I don’t try “installing” into the MintMenu system via a .desktop file. Then it fails the same way. Some odd permissions business, perhaps.