Help loading html files into iOs native browser on iPad

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
w.wartersGA0dc3
Posts: 11
Joined: Mon Dec 05, 2011 5:33 pm

Help loading html files into iOs native browser on iPad

Post by w.wartersGA0dc3 » Thu Feb 16, 2012 7:05 pm

Hi folks.
I'm hoping someone can enlighten me as to how to properly point to and load local html files, ideally including fancy jquery effects, within an ipad build. I used the standalone settings to add files, first trying a full directory with css and javascript and html, and now just a simple html text file, but I can't seem to wrap my head around how to create a variable that will store a proper path to the file and then have it loaded into the ios native browser. Here's a sample line of code from my onpreOpenCard handler that fails if I try pointing to a local file which I assume is in the "engine" specialFolderPath

iphoneControlSet sBrowserId, "url", "htmltest.html"

I have also tried numerous approaches including code referencing specialFolderPath("engine") to put the path into a variable, and I'm missing something... (Note: I tried posting a sample here and the board won't let me submit it due to lack of permissions)

Anybody have experience using the ios native browser to display locally stored files? Your help and examples would make my day.
Thanks!

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Help loading html files into iOs native browser on iPad

Post by Klaus » Thu Feb 16, 2012 7:31 pm

Hi w.wartersGA0dc3

I'm not sure, but try this:
...
put "file://" & specialfolderpath("engine") & "/htmltest.html" into tFile
iphoneControlSet sBrowserId, "url",tFile
...
Or three SLASHES after file?
Don't have an iOS license, please try both solutions if one does not work.


Best

Klaus

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Help loading html files into iOs native browser on iPad

Post by Klaus » Thu Feb 16, 2012 7:32 pm

Ah, and welcome to the forum :D

w.wartersGA0dc3
Posts: 11
Joined: Mon Dec 05, 2011 5:33 pm

Re: Help loading html files into iOs native browser on iPad

Post by w.wartersGA0dc3 » Thu Feb 16, 2012 8:57 pm

Thanks for the response Klaus. I was unfortunately unsuccessful using your suggestions. I also tried changing the "file://" part to http with no luck. I wonder, does the iOs browser require parameters to enable local files (or for that matter, javascript)?

w.wartersGA0dc3
Posts: 11
Joined: Mon Dec 05, 2011 5:33 pm

Re: Help loading html files into iOs native browser on iPad

Post by w.wartersGA0dc3 » Thu Feb 16, 2012 9:11 pm

I came across this mysterious advice and modified it for the Engine special folder and my html file and it worked!

Code: Select all

put (specialFolderPath("Documents") & "/lunch.pdf") into theUrl
replace " " with "%20" in theUrl -- don't ask, just do it 
iphoneControlSet browserID, "url", theUrl

Jellicle
Posts: 453
Joined: Thu Feb 24, 2011 11:07 am

Re: Help loading html files into iOs native browser on iPad

Post by Jellicle » Thu Feb 16, 2012 10:08 pm

Pleased to be of assistance :)

Gerry
14" MacBook Pro
Former LiveCode developer.
Now recovering.

FireWorx
Posts: 362
Joined: Wed Sep 07, 2011 9:39 pm

Re: Help loading html files into iOs native browser on iPad

Post by FireWorx » Fri Feb 17, 2012 6:32 pm

Hi,
Dixie got me started loading PDF's into the IOS browser with his cool little mapping ap. Taking a look at Gerry's cool little Ap gave me some ideas as well and the little stack he uploaded at the lnk below took me even farther as far as altering HTML on the fly and displaying it in live code.

http://forums.runrev.com/viewtopic.php? ... css#p38382

I am now altering HTML code based on user input and displaying scrolling HTML lists to the user with a couple image links on the far right of each line. These images are dead links (they go no where) their only purpose is to give me feed back via the

on browserLoadRequest pURL command.

In other words I will have two images displayed that contain href links named edit_1234 and delete_1234 (1234 being the unique ID number from the database record and assigned to the HTML through a repeat loop) The command above will return "edit_1234" or "delete_1234" depending on which image is clicked from which line in the scrolling list. I then close the browser out and jump back into live code to alter the SQlite database (to either edit or delete record 1234) and move on. This was easier for me to do than learn how to create scrolling lists with images in a data grid. Gives you a lot of options for text styles etc as well. Lists scroll smoothly which I understand has been an issue in LC. If I get a chance I will upload a sample stack soon.
Thanks to Dixie and Jerry for getting me started.
Dave

w.wartersGA0dc3
Posts: 11
Joined: Mon Dec 05, 2011 5:33 pm

Re: Help loading html files into iOs native browser on iPad

Post by w.wartersGA0dc3 » Tue Apr 10, 2012 6:11 pm

The annoying problem I had with loading local files stored in your app into a browser comes down to a problem with failed url encoding of the file location information. The workaround that people use (and which took me days to discover) requires replacing spaces with %20 programmatically before sending the file link to the browser. Creating a function to handle this repeating problem really makes sense. See this blog post by Obleo for an example.
intkeystrokes.posterous[dot]com/viewing-local-file-in-uiwebview-in-ios-with-l

goodeggclub
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7
Joined: Tue Sep 18, 2012 2:43 pm

Re: Help loading html files into iOs native browser on iPad

Post by goodeggclub » Tue Sep 18, 2012 2:59 pm

Hello w.wartersGA0dc3 and LiveCode forum members.

I am new to Live Code and am trying to develop a mobile app that loads local html files into a browser object, but am having a hard time getting started. Could you share a sample of the code or stack that got you over the hump?

Thank you.
Russ
Russell McCabe - Lead Developer

"To the man who only has a hammer, every issue he encounters looks like a nail."

http://goodeggclub.com

Post Reply