What is the best way to load a webpage using HTMLViewer1.LoadURL? I am using Xojo 2021r3.1 for a web project. I want to be able to store the file in the application directory. I want it to work in debug mode and when deployed to a server.

If you’re wanting to load a static HTML file from your site you would use LoadHTML and you would use a copyfile build step to copy the file during the build process. A better place for the file would be in the resources folder, not the application folder.

What example code could I use?

You would use something like

Sub Shown() Handles Shown
  Var Document As TextInputStream = TextInputStream.Open(SpecialFolder.Resources.Child("Document.html"))
End Sub

which is the shown event of the htmlviewer control on your page/container.

Worked great. The only problem I had was how to use “copy files” to place the file in the resources directory.
The file kept disappearing until I found out the Build step “copy files” needed to be dragged and dropped to just under the build icon(s). After that the code worked great.


You could also drop the file into the left pane of the project. That places it in Resources.