Getting Browser Widget to Read Local Assets

hh hh at hyperhh.de
Fri Jan 11 09:58:20 EST 2019


Field and button names below relate to my example stack.
http://forums.livecode.com/viewtopic.php?p=173867#p173867

To use a local file (= NOT from a local or remote server) you have
to load the image from a stack property or url("binfile:"...) and
add it inline (base64 encoded):

Step 1: imageVariable = stack property or url("binfile:"...)
Step 2: put base64Encode(imageVariable) into b64Data
Step 3: replace linefeed with empty in b64Data --> IMPORTANT!!
Step 4: write in fld "HTML" of my example stack

background-image: url('data:image/jpg;base64,<b64Data>')

**** The width x height of the image to load and the width x height
of the loader in fld "HTML" should roughly coincide:
You don't really want to load a 1200x800 image as background
into a 192x128 rotating DOM object?

You could also do step 1 to 4 once and put compress(fld "HTML")
into a <stack property>, then set later on in btn "LoadURL" the
htmltext to decompress(<stack property>).
And if the image is large, then you could use in the script of
widget "Browser" of the example stack:

on hideloader
  delete widget "loader" --> instead of hide widget "loader"
end hideloader





More information about the use-livecode mailing list