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?
This sounds like use for WebSDK.
Not allowed by whom? By the law? By Xojo? By Web Browsers?
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.
If what you want to do is click on some of the links, you could simply use a HTTPSocket to get the page content.
You can then parse the content of the page, looking for ‘a href’ tags, and build a list of links.
Then no need to intervene in the page itself.
Tim, I had not realized that the WebSDK was doable in pure Xojo. Thanks for pointing it out, it sounds exactly like what I need.
look to [quote]Extras/WebSDK/Examples/HTMLArea.xojo_binary_project[/quote] that should implement a stub of exactly what you are trying to accomplish.
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.