Web HTML Viewer
From Xojo Documentation
The HTML Viewer control renders HTML (like any web browser application). Typically, this is used to display pages that are not part of the web application.
You can pass this control the HTML text itself or tell it to load the HMTL specified by a URL. If the HTML is valid, it renders it. You can specify the default URL via the URL property in the Inspector for the control.
The commonly used properties and methods are listed below. Refer to WebHTMLViewer in the Language Reference for the complete list.
- Specify the URL in the Inspector to set the web page that is displayed when the Web Viewer first opens. Changing the URL in code immediately causes the URL contents to load.
- Use this method to load HTML (as a string) that you provide. If you have HTML in a file you want to display, first load the file into a String (using a TextInputStream) and then use this method to load the HTML string.
- Prints the contents of the HTML Viewer (some browsers will print the entire web page).
- Used to display the web page at the supplied URL.
This code shows Wikipedia in a HTMLVIewer Viewer:
You can load HTML directly from a string:
To display HTML that is in a file, first load the file into a String and then call LoadPage:
If htmlFile <> Nil And htmlFile.Exists Then
Dim html As String
Dim htmlInput As TextInputStream
htmlInput = TextInputStream.Open(htmlFile)
html = htmlInput.ReadAll
Catch e As IOException
html = "<html><body><h1>Error loading file on server.</h1></body></html>"