how to load a local file into the browser widget?
klaus at major-k.de
Fri May 24 17:46:21 EDT 2019
> Am 24.05.2019 um 23:00 schrieb Tore Nilsen via use-livecode <use-livecode at lists.runrev.com>:
> Try to start the url with «file:/// <file:///>« this is what I get at the start of the url of a browser widget
> when i set the url from a script using «answer file» to navigate to any valid html file:
> on mouseUp
> answer file "Choose html file to display"
> set url of widget "browser" to it
> end mouseUp
>> 24. mai 2019 kl. 22:29 skrev Curt Ford via use-livecode <use-livecode at lists.runrev.com>:
>>> You must make sure that the filePath to the html file you would like to see does not contain any invalid characters like spaces, which you will find is OK by the file system but not with the browser.
>> I had wondered about this; I renamed the file to "Browsertryout" and moved it to the desktop (so there were no spaces in the filePath, which is now "file://Users/cford/Desktop/Browsertryout.app/Contents/MacOS/Future.html"), but I'm still getting the same result (a blank widget).
it is TWO slashes actually -> file://
The third slash is from the actual filename -> /Users/cford/Desktop/Browsertryout.app/Contents/MacOS/Future.html
But why on earth are you always messing around with the DEFAULTFOLDER when we these lovely specialfolderpath() functions? 8-)
Do like this:
1. Add your files (hmtl, images, videos, sounds or whatever) to your standalone via the "Standalone Application Settings" -> "Copy files"
2. Then you will find them in your standalone in -> specialfolderpath("resources") on ANY platform
You can also use -> specialfolderpath("resources") in the IDE, where it points to the folder containing the executing stack.
Keep all your files (and folders) in that folder and with that and 1. above you do not need to script something different
for the IDE and standalone on ANY platform!
3. Do this to display the html file in a browser widget:
put specialfolderpath("resources") & "/Future.html" into tFile
## Important, if the pathname contains spaces:
replace " " with "%20" in tFile
set the url of widget "el browsero" to tFile
Be aware that iOS and Android are case-sensitive operating systems: Future.html <> future.html
So it may be a good idea to name all of your files with lowercase and your are on the safe side.
klaus at major-k.de
More information about the use-livecode