Load HTML

Hey all, how could I load an HTML file that i have dragged into my project?

I’ve tried:

Window Open Event

Var MyList() as String

MyList.add("Test HTML")

Var Item as String
for each item in MyList
  Listbox1.AddRow(item)
next

And in the Listbox1 Change event:

    If Listbox1.Selected(0) = True then
      HTMLViewer1.LoadHTML (TestHTML)
    end if

// TestHTML is the name of the HTML file that I have placed into the project

The error im getting is:

Window1.Listbox1.Change, line 2

Type "HTMLViewer" has no member named "LoadHTML"
HTMLViewer1.LoadHTML (TestHTML)

Thank you in advance!

LoadPage?

You have the signature wrong if TestHTML is a String.

https://docs.xojo.com/HTMLViewer.LoadPage

Sorry TestHTML is the name of the HTML file i have dragged into my project.

Are you creating a Desktop project or a Web project?

Desktop project. I am probably going about this the wrong way. I am wanting to display text and images in one control like a TextArea or HTMLviewer.

See the docs here HTMLViewer - Xojo Documentation
there is no .LoadHTML for desktop projects

2 Likes

Hi Robin, you want to show an html file on an htmlviewer by selecting a row in a listbox, right?
this code goes in the change event of the listbox:
var testHTML As FolderItem

testHTML = SpecialFolder.Documents.Child(“Xojo\TestHTML.htm”)

If Listbox1.Selected(0) = True then
HTMLViewer1.LoadPage(TestHTML)
end if

1 Like

Hi Roger, Thank you for the reply. The code returns the following error

Window1.Listbox1.Change, line 3


This item does not exist
testHTML = SpecialFolder.Documents.Child(“Xojo/TestHTML.html”)

Highlighting the "Xojo

Is Xojo a folder you made?
Then that is a child also

Hi Robin,

I have done it in my 2021 version 1 of xojo like this:
testHTML = SpecialFolder.Documents.Child(“Xojo\When Recodering\TestHTML.htm”)
that is the full path to the html file and it works.

Hi Robin,
Did you do this : “Xojo/TestHTML.htm”
or did you use this : “Xojo\TestHTML.htm”
You have to use “Xojo\TestHTML.htm”
watch the backslash please.

1 Like

Roger, I tried it the way you told me too and it’s giving me the same error. Apologies I’m not near the computer for the rest of the day, ill post exactly what I’m doing first thing.

I really do appreciate your help!

Hi Robin,
It’s oke don’t worry about it.
I have made a video for you, hope that will help you.

or if you go to youtube enter my name with xojo behind it and you will find me.

1 Like

@Roger_van_Leeuwen

I thought the name looked familiar, I found your videos on YouTube some time ago and have watched them
Thanks for making them (I also subscribed to your channel) :+1:

Hi Brian,
Thank you, I like to help this guy out.
I though, lets try it with a video.
There are many more video’s to come.

1 Like

Robin in an early message you wrote : ```
Window1.Listbox1.Change, line 3

This item does not exist
testHTML = SpecialFolder.Documents.Child(“Xojo/TestHTML.html”)

Highlighting the "Xojo

the highlighting Xojo part is a folder, that is on my computer not on your computer.
You need to adjust that path to where ever you have that TestHTML file in your computer..
Do something for me, put the TestHTML file in your document folder, not in a file or anything else.

Then type this  : 

var testHTML as folderitem
testHTML = SpecialFolder.Documents.Child(“TestHTML.html”)

If Listbox1.Selected(0) = True then
  HTMLViewer1.LoadPage(TestHTML)
end if

You got that error because you don't have a folder called Xojo in your documents.
2 Likes

Roger, that worked! It was wrecking my brain what I was doing wrong.

Thank you so much for the video, that also helped!

Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.