Page 1 of 1
Browser widget and local files?
Posted: Fri Apr 11, 2025 11:20 am
by richmond62
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:
-
-
https://richmondmathewson.owlstown.net/
Re: Browser widget and local files?
Posted: Fri Apr 11, 2025 11:32 am
by richmond62
Hmm:
viewtopic.php?t=27630
would it be possible to set the
specialFolderPath to inside a Mac App bundle?
Re: Browser widget and local files?
Posted: Fri Apr 11, 2025 12:13 pm
by Klaus
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
Re: Browser widget and local files?
Posted: Fri Apr 11, 2025 3:57 pm
by FourthWorld
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?
Re: Browser widget and local files?
Posted: Fri Apr 11, 2025 3:59 pm
by Klaus
Yes, sure!

Re: Browser widget and local files?
Posted: Fri Apr 11, 2025 4:21 pm
by SWEdeAndy
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.
Re: Browser widget and local files?
Posted: Fri Apr 11, 2025 4:33 pm
by Klaus
I always use this to get the complete pathname:
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.
Re: Browser widget and local files?
Posted: Sat Apr 12, 2025 5:48 pm
by bobcole
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.
Re: Browser widget and local files?
Posted: Sat Apr 12, 2025 5:56 pm
by Klaus
Hi Bob,
thanks a lot, I somehow missed the two leading slashes //.
Works as advertized now!
Best
Klaus