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

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Yann
Posts: 32
Joined: Wed Oct 13, 2010 9:55 am

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

Post by Yann » Wed Oct 19, 2016 1:40 pm

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 :)

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

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

Post by Klaus » Wed Oct 19, 2016 2:41 pm

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

Yann
Posts: 32
Joined: Wed Oct 13, 2010 9:55 am

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

Post by Yann » Wed Oct 19, 2016 3:43 pm

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.

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

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

Post by Klaus » Thu Oct 20, 2016 1:32 pm

Hmmm, sorry, no brilliant idea in the moment...

colourpixels
Posts: 83
Joined: Mon Oct 31, 2011 5:28 am

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

Post by colourpixels » Thu Nov 03, 2016 1:11 am

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

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

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

Post by Klaus » Thu Nov 03, 2016 12:28 pm

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

Yann
Posts: 32
Joined: Wed Oct 13, 2010 9:55 am

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

Post by Yann » Wed Dec 05, 2018 10:53 am

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 !

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

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

Post by FourthWorld » Wed Dec 05, 2018 8:14 pm

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.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply

Return to “iOS Deployment”