Browser widget and local files?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- Livecode Opensource Backer
- Posts: 10078
- Joined: Fri Feb 19, 2010 10:17 am
Browser widget and local files?
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/
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/
-
- Livecode Opensource Backer
- Posts: 10078
- Joined: Fri Feb 19, 2010 10:17 am
Re: Browser widget and local files?
Hmm:
viewtopic.php?t=27630
would it be possible to set the specialFolderPath to inside a Mac App bundle?
viewtopic.php?t=27630
would it be possible to set the specialFolderPath to inside a Mac App bundle?
Re: Browser widget and local files?
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.
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
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
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
-
- VIP Livecode Opensource Backer
- Posts: 10043
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Browser widget and local files?
Does the local copy of the page render well in your browser, outside of LC?richmond62 wrote: ↑Fri Apr 11, 2025 11:20 amLet 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:
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Browser widget and local files?
Yes, sure! 

Re: Browser widget and local files?
This works perfectly well for me:
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.
Code: Select all
answer file "Select file"
set the URL of widget "MyBrowser" to "file:" & 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
Independent app and system developer
Free LC dev tools: https://github.com/wheninspace
(WIS_WebDeployHelper, WIS_ScriptDependencies, WIS_BrowserAnimation)
WhenInSpace: https://wheninspace.com
Re: Browser widget and local files?
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.
Code: Select all
answer file "sdasdasdasd"
put it

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?
The dictionary says "set the URL of widget to pUrl" is the command.
Therefore to display the document, place this in front like this:
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.
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
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?
Hi Bob,
thanks a lot, I somehow missed the two leading slashes //.
Works as advertized now!
Best
Klaus
thanks a lot, I somehow missed the two leading slashes //.
Works as advertized now!

Best
Klaus