loadURL for local files

Hello.

I know LoadPage can be used to load HTML files into an HTMLViewer but is there way to load the page as if it was a local file:// URL?

I ask because I have already a lot of logic in javascript to handle URL parameters and anchors and it would be easier to load just send the full url with parameters.

The URL loads properly in a browser if local file restrictions is disabled in the developer menu.

I want to do something like file://path/to/file.html?img=/path/to/image.png#halfsize so I can get the “img” parameter and the “halfsize” anchor as parameters on load.

I can try and executeJavascript but the functions are deeply tied to page load events and I’d rather not refactor it.

Or, if you’re displaying images, you could process them yourself in a Canvas instead of having the tremendous overhead of a HTML Viewer, HTML Rendering engine, and Javascript to resize an image. Xojolectron basically.

You can use the URLPath of a FolderItem to get a path usable with HTMLViewer.

[quote=402299:@Tim Parnell]Or, if you’re displaying images, you could process them yourself in a Canvas instead of having the tremendous overhead of a HTML Viewer, HTML Rendering engine, and Javascript to resize an image. Xojolectron basically.

You can use the URLPath of a FolderItem to get a path usable with HTMLViewer.[/quote]

The sample code was just an example to illustrate what I wanted to do. What I run in the HTMLViewer is a full-blown PDF interpreter written in JavaScript and I’m not crazy enough to try and re-created natively in Xojo :slight_smile:

It was for this: https://github.com/eduo/XojoPdfJs/ . In the past I’d always used this library sending parameters through the URL. What I did for this was sending them directly through JavaScript.

I didn’t care about possible overheard of running an HTML renderer and JavaScript engine because it’s a proof of concept and it’s left as an exercise to whomever wants to take a look at it.

I would expect that to work but make sure you call EncodeUrlComponent on that image path. I don’t think forward slashes are allowed in a url parameter value.

Isn’t this what an URLPath is for?

one slash more ?

[quote]
file:///path/to/file.html?img=/path/to/image.png#halfsize[/quote]

The problem is that the parameters were not being accepted. In the end I couldn’t make it work so I turned it around to send javascript commands directly. ¯\(?)