# loadURL for local files

**URL:** <https://forum.xojo.com/t/loadurl-for-local-files/44981>\
**Category:** General\
**Created:** [August 23, 2018, 6:56pm UTC](https://forum.xojo.com/t/loadurl-for-local-files/44981 "2018-08-23T18:56:25Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eduardo\_Gutierrez\_de\_Oliveira](https://forum.xojo.com/user_avatar/forum.xojo.com/eduardo_gutierrez_de_oliveira/32/264_2.png) [@Eduardo\_Gutierrez\_de\_Oliveira](https://forum.xojo.com/u/Eduardo_Gutierrez_de_Oliveira)\
**Post date:** [August 23, 2018, 6:56pm UTC](https://forum.xojo.com/t/loadurl-for-local-files/44981/1 "2018-08-23T18:56:25Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Tim\_Parnell](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_parnell/32/161_2.png) [@Tim\_Parnell](https://forum.xojo.com/u/Tim_Parnell)\
**Post date:** [August 23, 2018, 7:29pm UTC](https://forum.xojo.com/t/loadurl-for-local-files/44981/2 "2018-08-23T19:29:55Z")

</div>

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`.

---

<div class="post-metadata">

**Author:** ![Eduardo\_Gutierrez\_de\_Oliveira](https://forum.xojo.com/user_avatar/forum.xojo.com/eduardo_gutierrez_de_oliveira/32/264_2.png) [@Eduardo\_Gutierrez\_de\_Oliveira](https://forum.xojo.com/u/Eduardo_Gutierrez_de_Oliveira)\
**Post date:** [August 23, 2018, 9:08pm UTC](https://forum.xojo.com/t/loadurl-for-local-files/44981/3 "2018-08-23T21:08:33Z")

</div>

[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 🙂

It was for this: [https://github.com/eduo/XojoPdfJs/](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.

---

<div class="post-metadata">

**Author:** ![Greg\_O\_Lone](https://forum.xojo.com/user_avatar/forum.xojo.com/greg_o_lone/32/49_2.png) [@Greg\_O\_Lone](https://forum.xojo.com/u/Greg_O_Lone)\
**Post date:** [August 24, 2018, 12:40pm UTC](https://forum.xojo.com/t/loadurl-for-local-files/44981/4 "2018-08-24T12:40:24Z")

</div>

> [@402286:@Eduardo Gutierrez de Oliveira](#):
>
> 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 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.

---

<div class="post-metadata">

**Author:** ![Beatrix\_Willius](https://forum.xojo.com/user_avatar/forum.xojo.com/beatrix_willius/32/282_2.png) [@Beatrix\_Willius](https://forum.xojo.com/u/Beatrix_Willius)\
**Post date:** [August 24, 2018, 1:00pm UTC](https://forum.xojo.com/t/loadurl-for-local-files/44981/5 "2018-08-24T13:00:56Z")

</div>

Isn’t this what an URLPath is for?

---

<div class="post-metadata">

**Author:** ![Axel\_Schneider](https://forum.xojo.com/user_avatar/forum.xojo.com/axel_schneider/32/465_2.png) [@Axel\_Schneider](https://forum.xojo.com/u/Axel_Schneider)\
**Post date:** [August 24, 2018, 4:21pm UTC](https://forum.xojo.com/t/loadurl-for-local-files/44981/6 "2018-08-24T16:21:38Z")

</div>

> [@402286:@Eduardo Gutierrez de Oliveira](#):
>
> 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.

one slash more ?

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

---

<div class="post-metadata">

**Author:** ![Eduardo\_Gutierrez\_de\_Oliveira](https://forum.xojo.com/user_avatar/forum.xojo.com/eduardo_gutierrez_de_oliveira/32/264_2.png) [@Eduardo\_Gutierrez\_de\_Oliveira](https://forum.xojo.com/u/Eduardo_Gutierrez_de_Oliveira)\
**Post date:** [August 24, 2018, 6:16pm UTC](https://forum.xojo.com/t/loadurl-for-local-files/44981/7 "2018-08-24T18:16:03Z")

</div>

> [@402433:@Axel Schneider](#):
>
> one slash more ?

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. ¯\_(?)_/¯

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [October 29, 2020, 7:20pm UTC](https://forum.xojo.com/t/loadurl-for-local-files/44981/8 "2020-10-29T19:20:41Z")

</div>


