Load HTML file within the app

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
michel_bujardet
Posts: 45
Joined: Mon Apr 21, 2014 10:41 am
Contact:

Load HTML file within the app

Post by michel_bujardet » Sat May 03, 2014 12:45 pm

I am trying to open an HTML file stored in my app instead of an URL.

I added index.html in the Copy Files section of the Standalone Applications settings and have modified the initial url of the browser lesson to :

Code: Select all

mobileControlSet sBrowserId, "url", "file:" & specialFolderPath("engine") & "/index.html"
Nothing displays. I tried file:// as well, no luck. What am I missing ?

Thank you.

Mitch
http://FontMenu.com

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: Load HTML file within the app

Post by Dixie » Sat May 03, 2014 12:56 pm

Store the html file in a custom property... then when the stack opens move the custom property into a file... as in

Code: Select all

 /*put the custom property cMap into a file 'dvNav.html' in the documents folder */
      put the cMap of this stack into URL("file:" & specialFolderPath("documents") & "/dvnav.html" ) 
Then when you want to build your browser

Code: Select all

      if browserID is empty then 
         put "file://" & specialFolderPath("documents") & "/dvnav.html" into theURL
         replace space with "%20" in theURL
         put 0,44, the width of this card, the height of this card into theSize
         
         mobileControlCreate "browser"
         put the result into browserID
         mobileControlSet browserID, "url", theURL
         mobileControlSet browserID, "rect", theSize
         mobileControlSet browserID, "autofit",true
         mobileControlSet browserID, "delayRequests", true
         mobileControlSet browserID, "dataDetectorTypes", "link, calendar event, phone number, address"
         mobileControlSet browserID, "visible", "true"
      end if
Attached a stack that will display a 'google map' when you run in the simulator. Look in the custom properties of the stack and you will see the html file...

Hope it helps...:-)
Attachments
googleMapiOS.livecode.zip
(3.42 KiB) Downloaded 242 times

michel_bujardet
Posts: 45
Joined: Mon Apr 21, 2014 10:41 am
Contact:

Re: Load HTML file within the app

Post by michel_bujardet » Sat May 03, 2014 7:55 pm

Dixie wrote:Store the html file in a custom property... then when the stack opens move the custom property into a file... as in
Dear Dixie,

I slightly modified your code, and it now works beautifully :

Code: Select all

         put "file://" & specialFolderPath("engine") & "/index.html" into theURL

         replace space with "%20" in theURL
         put 10,0, the width of this card-20, the height of this card-50 into theSize
         
         mobileControlCreate "browser"
         put the result into browserID
         mobileControlSet browserID, "url", theURL
         mobileControlSet browserID, "rect", theSize
         mobileControlSet browserID, "autofit",true
         mobileControlSet browserID, "delayRequests", true
         mobileControlSet browserID, "dataDetectorTypes", "link, calendar event, phone number, address"
         mobileControlSet browserID, "visible", "true"
Thank you so much !
:)

Mitch
http://FontMenu.com

Post Reply