Page 1 of 1

iOS Browser widget : can we serve a whole local site ?

Posted: Wed Oct 19, 2016 1:40 pm
by Yann
Hi,

Could somebody please explain how to set up the browser widget so that it can get all its content (html, js, css) from local files in a given folder, with fully functional relative links ?

All I can do for the moment is this :

Code: Select all

set the htmltext of widget "Browser" to textdecode (url ("file:" & specialFolderPath("resources") & "/web/html/index.html"), "utf8" ) 
But it will just display the page's embedded html + js + css, leaving all relative links unreachable. I suppose this is due to the fact that the browser is pointed to a dummy url, which I have no idea how to deal with.

Is there perhaps a solution based on a "localhost" url scheme, or is such a thing simply impossible at the moment ?

Thank you in advance :)

Re: iOS Browser widget : can we serve a whole local site ?

Posted: Wed Oct 19, 2016 2:41 pm
by Klaus
Hi Yann,

I don't develop for mobile, but doesn't this work?
This is the (more or less) official way to display a local page in a browser:

Code: Select all

...
set the URL of widget "Browser" to ("file://" & specialFolderPath("resources") & "/web/html/index.html")
...
Best

Klaus

Re: iOS Browser widget : can we serve a whole local site ?

Posted: Wed Oct 19, 2016 3:43 pm
by Yann
Hi Klaus,

Thanks, but unfortunately it doesn't work. Although the constructed url is perfectly valid (a "put url" in the message box will return the whole page's content), the browser widget rejects it, both in the editor which raises an "Error description: extension: error occured with domain" error message, and in the iOS executable where the browser remains blank.

Re: iOS Browser widget : can we serve a whole local site ?

Posted: Thu Oct 20, 2016 1:32 pm
by Klaus
Hmmm, sorry, no brilliant idea in the moment...

Re: iOS Browser widget : can we serve a whole local site ?

Posted: Thu Nov 03, 2016 1:11 am
by colourpixels
When testing I found it didn't work unless I escaped the path, as the spaces in folder names were killing it. (ie it needed %20 in between).

Re: iOS Browser widget : can we serve a whole local site ?

Posted: Thu Nov 03, 2016 12:28 pm
by Klaus
Ah, yes, slap forehead! :D

I always forget about the SPACES problem in URLs, try this:

Code: Select all

...
put specialFolderPath("resources") & "/web/html/index.html" into tUrl
replace SPACE with "%20" in tUrl
set the URL of widget "Browser" to ("file://" & tUrl)
...

Re: iOS Browser widget : can we serve a whole local site ?

Posted: Wed Dec 05, 2018 10:53 am
by Yann
Guys, sorry for resurrecting a 2-year-old thread, but I had missed the notifications for your answers and just wanted to thank you very much :)

In the meantime, I had came to the false conclusion that it couldn't work, and turned to another platform that satisfied this particular need in a more obvious way... but now, thanks to you, back to LiveCode !

Re: iOS Browser widget : can we serve a whole local site ?

Posted: Wed Dec 05, 2018 8:14 pm
by FourthWorld
FWIW, keep in mind that most browsers will not run JavaScript from local files. If the pages do not use JS you should be fine, but if they do you may see differences between platforms, if it runs at all on any of them.