Browser widget and local files?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10078
Joined: Fri Feb 19, 2010 10:17 am

Browser widget and local files?

Post by richmond62 » Fri Apr 11, 2025 11:20 am

Let us suppose I have a very basic stack with a single browser widget in it . . .

Now I have an HTML document stored locally that I wish to display in that browser, but seem not to be able to . . .
-
Screenshot 2025-04-11 at 13.15.09.jpg
-
Quite obviously I have NO problem displaying the same web page at its location on the internet:
-
Screenshot 2025-04-11 at 13.21.37.jpg
-
https://richmondmathewson.owlstown.net/

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10078
Joined: Fri Feb 19, 2010 10:17 am

Re: Browser widget and local files?

Post by richmond62 » Fri Apr 11, 2025 11:32 am

Hmm:

viewtopic.php?t=27630

would it be possible to set the specialFolderPath to inside a Mac App bundle?

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

Re: Browser widget and local files?

Post by Klaus » Fri Apr 11, 2025 12:13 pm

Hi Richmond,

1. the url needs to be correctly encoded, but even that does not work here, tested with LC 9.6.13 and 10.

Code: Select all

on mouseUp
   put "/Volumes/1TB/Livecode Hilfe/x-on-limit/Website/index.html" into tUrl

   ## NO spaces in URLs
   replace " " with "%20" in tUrl
   
   ## blank page :-/
   set the url of widget 1 to ("file:" & tUrl)

   ## RESULT = EMTPY?
   put the result
end mouseUp
This is exactly what the dictionary suggests, no idea what is going wrong...

2. we cannot SET a specialfolderpath, but -> specialfolderpath("resources") is the folder inside a Mac app package,
where you find all the files and folders you added via "Copy files..." in the "Standalone Application Settings".

Best

Klaus

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10043
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Browser widget and local files?

Post by FourthWorld » Fri Apr 11, 2025 3:57 pm

richmond62 wrote:
Fri Apr 11, 2025 11:20 am
Let us suppose I have a very basic stack with a single browser widget in it . . .

Now I have an HTML document stored locally that I wish to display in that browser, but seem not to be able to . . .

Quite obviously I have NO problem displaying the same web page at its location on the internet:
Does the local copy of the page render well in your browser, outside of LC?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

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

Re: Browser widget and local files?

Post by Klaus » Fri Apr 11, 2025 3:59 pm

Yes, sure! :-)

SWEdeAndy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 324
Joined: Sat Aug 16, 2008 9:48 am
Contact:

Re: Browser widget and local files?

Post by SWEdeAndy » Fri Apr 11, 2025 4:21 pm

This works perfectly well for me:

Code: Select all

   answer file "Select file"
   set the URL of widget "MyBrowser" to "file:" & it
If you still get a blank browser, then delete the browser widget and add a fresh one. It can get stuck somehow, especially if you've gone forth and back between setting the url and setting the htmlText of it.
Andreas Bergendal
Independent app and system developer
Free LC dev tools: https://github.com/wheninspace
(WIS_WebDeployHelper, WIS_ScriptDependencies, WIS_BrowserAnimation)
WhenInSpace: https://wheninspace.com

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

Re: Browser widget and local files?

Post by Klaus » Fri Apr 11, 2025 4:33 pm

I always use this to get the complete pathname:

Code: Select all

answer file "sdasdasdasd"
put it
Then copy/paste to avoid typos and to write down the complete pathname. :-)
Tried with a couple of "fresh" browser widgets, evern restarted LC and tried this with a new stack and widget, NO DICE!?

Tested with LC 9.6.13 and 10.0.0.

bobcole
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 161
Joined: Tue Feb 23, 2010 10:53 pm

Re: Browser widget and local files?

Post by bobcole » Sat Apr 12, 2025 5:48 pm

The dictionary says "set the URL of widget to pUrl" is the command.
Therefore to display the document, place this in front like this:

Code: Select all

file:///Users/richmond/Desktop/Hax 11 April/Test/Richmond Mathewson.html
Note that there are three slashes in front.
Save and close the file. <--Important, I think.
Re-open the file.
It should work.
Bob

Note: the file name may contain spaces.

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

Re: Browser widget and local files?

Post by Klaus » Sat Apr 12, 2025 5:56 pm

Hi Bob,

thanks a lot, I somehow missed the two leading slashes //.
Works as advertized now! :-)

Best

Klaus

Post Reply