iOS Question Can't load asset files using a WebView

netkomm

Active Member
Licensed User
Longtime User
Hi,

I have the following HTML code that is used as a template. It uses jquery and another library to create a chart.

If I load directly the html file into the web view it work without any error.

However I need to first load the HTML document to a string, replace the content that needs to be customised and then I can load the wev view.

So, this is the original head of the HTML file

B4X:
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <title></title>
        <script type="text/javascript" language="javascript" src="jquery.min.js"></script>
        <script type="text/javascript" language="javascript" src="echarts.min.js"></script>
    </head>

I have tried to put the HTML into a string so that I can do the following

B4X:
Dim js1,js2,score_text As String
js1 = File.Combine(File.DirAssets, "jquery.min.js")
js2 = File.Combine(File.DirAssets, "echarts.min.js")
score_text ="<html><head><meta http-equiv='content-type' content='text/html; charset=utf-8' /><title></title><script type='text/javascript' language='javascript' src='" & js1 & "'></script><script type='text/javascript' language='javascript' src='" & js2 & "'></script></head>"

but the output won't show up in the webview.

Where is that I am messing it up? :D

Thanks for your help

PS: I shortened up the HTML for convenience... the file is actually quite big. :)
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Use XUI.FileUri to create the asset url.

Tip: use smart strings:
B4X:
Dim js1,js2,score_text As String
js1 = XUI.FileUri(File.DirAssets, "jquery.min.js")
js2 = XUI.FileUri(File.DirAssets, "echarts.min.js")
score_text =$"<html><head><meta http-equiv='content-type' content='text/html; charset=utf-8' /><title></title><script type='text/javascript' language='javascript' src='${js1}'></script><script type='text/javascript' language='javascript' src='${js2}'></script></head>"$
 
Upvote 0

netkomm

Active Member
Licensed User
Longtime User
Hi Erel,

Which library includes the XUI object? On my end it throws an error...

(using 4.4 beta with remote builder)
 
Upvote 0
Top