Get JavaScript variables back from HTMLViewer without changing the title.

There’s a way to do this on macOS with the WKWebView engine and the WKScriptMessageHandler but (A) I think Xojo is using the older WebView engine, and (B) this code is in Swift. Perhaps it could be adapted?
https://medium.com/@tonespy/communicating-between-angular-javascript-in-wkwebview-and-native-code-368e6941d7f5

We have that in MBS Plugins.

See WKWebViewControlMBS control

Isn’t TitleChanges the only one cross-platform?

What’s updated from JavaScript with StatusChanged, that triggers the event?

Inside your HTMLViewer you do:

window.status = "some string";

which triggers the statuschanged event. Then that string is presented to you in your Xojo statuschanged event handler for the HTMLViewer.

[quote=402431:@Tim Streater]Inside your HTMLViewer you do:

window.status = "some string";

which triggers the statuschanged event. Then that string is presented to you in your Xojo statuschanged event handler for the HTMLViewer.[/quote]

Duh. I’m an idiot, of course :slight_smile: Sorry, I’m not thinking straight.

Has anyone verified the limitations in length? I’ll try passing long text until I hit it.

The Window.Status method no longer works as of 2017r1 because of the CEF update.

Under Windows. Seems to still work OK for macOS 2018r2.

To sum up our javascript string functions, we have:

So we do have for Mac:
HTMLViewer.EvaluateJavaScriptMBS(code as string) as string

And WebKit 2.x for Mac 64-bit:
WKWebViewControlMBS.EvaluateJavaScript(JavaScript as String, Tag as String = “”)

For Linux with WebKit:
LinuxWebViewMBS.EvaluateScript(script as string) as string

For Windows with Internet Explorer:
HTMLViewer.IERunJavaScriptMBS(JavaScript as string) as boolean

For Windows with WebKit:
ChromiumBrowserMBS.ExecuteJavaScript(jsCode as string, scriptUrl as string, startLine as integer)

[quote=402439:@Christian Schmitz]To sum up our javascript string functions, we have:

So we do have for Mac:
HTMLViewer.EvaluateJavaScriptMBS(code as string) as string

And WebKit 2.x for Mac 64-bit:
WKWebViewControlMBS.EvaluateJavaScript(JavaScript as String, Tag as String = “”)

For Linux with WebKit:
LinuxWebViewMBS.EvaluateScript(script as string) as string

For Windows with Internet Explorer:
HTMLViewer.IERunJavaScriptMBS(JavaScript as string) as boolean

For Windows with WebKit:
ChromiumBrowserMBS.ExecuteJavaScript(jsCode as string, scriptUrl as string, startLine as integer)[/quote]
Do you have a replacement event for status?

We can’t make an event unless you’d use our control instead of Xojo’s.

That, I understand. In the event that status stopped working, I’d need an HTMLViewer-like control with a cross platform way of passing data from javascript running in the control, to a Xojo event.

Well, if the OS no longer calls the event, Xojo can’t pass it to you.

I was wondering about Tim’s comment. Looking about this I found this from @Bob Keeney last year saying precisely that StatusChanged no longer works: https://www.bkeeneybriefs.com/2017/03/xojo-2017-release-1/

Well, my app is using HTMLEdit and is receiving the statuschange event (macOS Mavericks, Xojo 2018r2); I just tried it. So there it is.

Yes, we get it, StatusChanged is fine on Mac. But since it’s not cross-platform it is not a solution.

HTMLEdit 2 from GraffitiSuite was entirely rewritten to chunk data out through TitleChanged for this very reason.

Well I do know that, in fact. It was when I was first testing out my app on Windows that I discovered this, then looked at titleChanged, then discovered titleChanged had a platform-dependent length limitation. But my only point was that Eduardo appeared to be saying that it didn’t work at all.

One for me to look at, then. Although I’d prefer Xojo to do something too.

I just made a new blog article today: HTMLViewer JavaScript communication for Xojo

I hadn’t tried it. I just mentioned that I’d read it didn’t work cross-platform (which is what I need it for).

Thanks to all, by the way. While I had used HTMLViewers a lot I had never had to get results back and it’s been very educational.

6 posts were split to a new topic: Returning Data to Xojo Web App