What is the current preferred method to get generated output from HTMLViewer? I have a few JS parsers (js-sequence-diagram, flowchart.js.org) which needs to process my source HTML and generates output that I want to capture so that I can incorporate into a larger HTML document from multiple sources. Thanks for advice on how best to accomplish.
Robert, just a detail. Unless you develop cross platform, it is a good idea to post in the channel corresponding to your platform : Mac, Windows, Linux. That way, answers will be tailored for that particular case. In this instance, the solution varies.
The way to send data back to Xojo from inside HTMLViewer on Windows and LInux is to change the title in JS, and catch that change in the TitleChanged event.
This in JS will trigger the title change :
document.title = "This is my message";
You need to discriminate between your own code, and the normal title. To do so, I use a prefix, for instance “data:”
document.title = "data:This is my message";
That way in TitleChanged I can do
dim Msg as string
If Left(newTitle, 5) = "Data:" then
Msg = Replace(newTitle, "Data:", "")
// Do whatever you need with Msg
end if
I am needing to return the generated output from processed HTML. It seems like there should be a way to save the generated HTML out rather than passing via a 4kb title value. Other options?
I load my html and the parser runs and presents the output diagram in html. How do I, 1) know when the js has finished executing ? and 2) trigger an event to copy the output into the title? Any example projects available?
#1 can be accomplished by making a hook in the javascript that sends a message out to Xojo when the js has finished. #2 you would create a function in Javascript to do so, or you can create an anonymous js function and execute it from Xojo with ExecuteJavascript. Then capture the data in TitleChanged, and piece it back together.