I’m trying to write my first Web app with Xojo. It’ll be a port of a working Desktop app.
I need to render some custom html in a window and need to react to clicks to links inside that html view, in order to update other controls in my window, or alter the html.
I am using a HTMLViewer control and call LoadPage to load my html code.
But I cannot find any event that lets me capture clicks on the links so that I can react to them.
How does one do that? Could I set the hrefs to some address that calls back to my app, perhaps?
Or does MBS offer something for that, like it does in desktop apps? I suspect there are no plugins for Web though, right?
By law. Well, by web browser security. The techniques have been proven to be used in malicious ways in the past, so as standard security you can’t operate javascript on an iframe displaying a different domain or protocol.
So that leaves creating URLs in my href links that directly call back into the app’s URL handler.
Anyone done that?
I mean, how does that work? I see that the framework creates links that refer to the session ID, so I guess I have to do that as well, but how do I receive those?
If you’re completely in charge of the HTML being displayed I would also recommend looking into the WebSDK. You can have your links trigger Xojo events that are session aware. This should all work if the only reason you were using a HTMLViewer was to display HTML you created.
You can react to a changed URL ie if they click a specific button that loads a specific page, you get an Event, and can Action that.
I use this to know if the user has paid for an item via PayPal, as I have told PayPal to jump to a specific web page (on my web site, saying Thank you) on completion of the sale.