Background Image

I would like my webpage to have a background image using a local file. If I just a remote URL, it works. But if I use a local file, it doesn’t. This is supposed to be easy.

This works:

me.Style.Value("background-image") = "url("

This doesn’t.

me.Style.Value("background-image") = "url(file://localhost/users/User/Pictures/website-background.png)"

I’ve read that it’s about browser security but is there any workaround?

System: Xojo 2023r4, Windows 10

Have a property on your page like this:

Private Property backgroundImage As WebPicture

Then load and set the WebPicture like so:

var f as FolderItem = SpecialFolder.Pictures.Child("website-background.png")
backgroundImage = new WebPicture(f)

me.Style.Value("background-image") = "url(" + backgroundImage.URL + ")"

I’ll be damned. Thanks, Anthony!

1 Like