Xojo Web App - Compose and Open HTML Page in New Window


I can compose a web page (for example: <html><body>hello world</body></html> “on the fly” in web edition - however how do I launch that code in a new window without maybe first saving the html to a file on the web server then calling Session.ShowURL(“my_local_url”, True) to open the content in a new window? Is there a way?

(I’m using Xojo Cloud and was trying to avoid writing, launching, then deleting temp files)

Kind regards, Andrew

Use HandleURL on a virtual subdirectory. It will let you do for instance http://mysite.com/whatever/index.html where whatever/index.html will trigger HandleURL and you will be able to print your code.

For the new window, see Open in new Window - Web - Xojo Programming Forum

Thank you Michel,

I had used HandleSpecialURL in the past to handle external requests. I had not considered using HandleURL or HandleSpecialURL from within the App itself.

Example Use:

' App
  ' Event Handlers
      Request.Print("[enter HTML here]" + EndOfLine) // first line of html code
      Request.Print("[enter HTML here]" + EndOfLine) // second line of html code
      Request.Print("[enter HTML here]" + EndOfLine) // third line of html code
      Request.Print("[enter HTML here]") // last line of html code, no EndOfLine necessary
      Request.Status = 200 // HTTP Response code of 200 means everything is OK (stops a 404 being displayed in some browsers)
      Return True
'End HandleURL

'placed where you wish to ShowURL by passing the request via HandleSpecialURL (or HandleURL) such as from the action event of a button
  ShowURL(App.URL + "/special/", True) //  setting the second param = True - will force the URL to open in a new window

Michel, your solution works exceptionally well. Thank you very much for sharing your advice.

Kind regards, Andrew

The same technique is a superb way to create indexable pages for Google.