HTMLViewer.LoadPage windows issue link internal

Hello,

I am having an issue with HTMLViewer on Windows and local HTML files. Maybe I am doing something wrong

I embed HTML files (and css + js) in the application using CopySteps.

copystep

In all the html files is use href to link to other pages and css/js files with relative path, starting with ./

The home page (index.html) displayed at the start is fine (css included) but there is a button that link to a index.html in a subfolder and when I click the button,

try
  var tDoc as FolderItem = SpecialFolder.Resource("release-notes").Child("index.html")
  me.HTMLViewer1.LoadPage(tDoc)
catch 
  
end try

Screenshots within the HTLMViewer
Home:

Page after the button:

Notes:

  • The rendering is fine on Edge
  • Added to the registry for IE11 rendering
  • Files are copied correctly to the folder in the resources of the application
  • If I load the file directly using loadpage, the page load correctly
  • Tried some solutions from the forum but I could not solve this
  • The website is generated with VuePress

Code of the sub page directly

try
  var tDoc as FolderItem = SpecialFolder.Resource("release-notes").Child("release-notes").Child("index.html")
  me.HTMLViewer1.LoadPage(tDoc)
catch 
  
end try

The href link is a follow:
href="./release-notes/index.html"

(It’s working fine on MacOS)

Xojo version: 2020R2.1
Windows 10

Thank you

Check and see what url you are getting in the CancelLoad event.

When getting the URL parameters in the CancelLoad event, I get the right path.

If I copy this path on Microsoft Edge, it’s working

C:\Users\Julien\Downloads\test-releasenotes\test-releasenotes\Debugtest-releasenotes\Debugtest-releasenotes Resources\release-notes\release-notes\index.html

Julien

Ah! So the problem is that it’s not a url though. The path that is in the link must be a URLpath which you can get from a FolderItem. Probably will look something like this:

file://C/Users/Julien/Downloads/test-releasenotes/test-releasenotes/Debugtest-releasenotes/Debugtest-releasenotes Resources/release-notes/release-notes/index.html

Thank you for the answer,

How should I change things to make it work ?

  • Should I modify the source file directly
  • Use CancelLoad to modify the URL?
  • Intercept the path in CancelLoad and load the file directly?
  • Other method

Julien

it depends largely on where the source is coming from. If it’s something that you are generating yourself then I’d say fix it in your generator. the src attribute for an image or link should never be anything other than an absolute or relative URL.

All the links in the files are relatives already in each files

href="./release-notes/index.html"

I can’t not set an absolute path in the href of the document as they are not generated by Xojo.

What about something like:

Var f as FolderItem, abspath as String
f = new FolderItem ("./release-notes/index.html")
abspath = f.NativePath

Found a solution by cancelling the CancelLoad and loading a new page on each click of links combined with a boolean.

But in the end, I just changed the renderer to webkit and everything is working fine. It’s adding a lot to the size of the app but it’s easier for me.

We ran across a similar issue and fixed this by creating an href link that started with “myfile://someidentifier” and then the CancelLoad event would fire and we could intercept and do something.