M manios Active Member Licensed User Longtime User Jun 27, 2012 #1 Hi all, Loading from the assets directory works OK WebView1.LoadUrl("file:///android_asset/help.html" but how can I load a file from the .DirInternal?
Hi all, Loading from the assets directory works OK WebView1.LoadUrl("file:///android_asset/help.html" but how can I load a file from the .DirInternal?
NJDude Expert Licensed User Longtime User Jun 27, 2012 #2 Like this: Code: Copy Dim HTML As String HTML = File.GetText(File.DirInternal, "help.html") WebView1.LoadHtml(HTML) Upvote 0
Like this: Code: Copy Dim HTML As String HTML = File.GetText(File.DirInternal, "help.html") WebView1.LoadHtml(HTML)
S Sarah Member Licensed User Longtime User Aug 30, 2013 #3 Is there a way to structure a file path so as to use LoadUrl for a file in DirInternal? The problem with loading html as text seems to be that relative links do not work. e.g. if you have a file called "help.html" in DirInternal and a file called "help.css" also in DirInternal then "help.html" does not see the "help.css" file, presumably because it is loaded without knowing its own file path. Upvote 0
Is there a way to structure a file path so as to use LoadUrl for a file in DirInternal? The problem with loading html as text seems to be that relative links do not work. e.g. if you have a file called "help.html" in DirInternal and a file called "help.css" also in DirInternal then "help.html" does not see the "help.css" file, presumably because it is loaded without knowing its own file path.
warwound Expert Licensed User Longtime User Aug 30, 2013 #4 Can you try something like this: Code: Copy WebView1.LoadUrl(File.Combine(File.DirInternal, "my_webpage.html")) Martin. Upvote 0
Can you try something like this: Code: Copy WebView1.LoadUrl(File.Combine(File.DirInternal, "my_webpage.html")) Martin.
S Sarah Member Licensed User Longtime User Aug 30, 2013 #5 Ignore my question, I found the answer in another post: http://www.b4x.com/android/forum/threads/problem-with-webview1-loadurl-and-dirinternal.14655/ Upvote 0
Ignore my question, I found the answer in another post: http://www.b4x.com/android/forum/threads/problem-with-webview1-loadurl-and-dirinternal.14655/
S Sarah Member Licensed User Longtime User Aug 30, 2013 #6 Thanks Martin but that didn't work. This is what does: Code: Copy web.LoadUrl("file:///" & File.DirInternal & "/page.html") Upvote 0
Thanks Martin but that didn't work. This is what does: Code: Copy web.LoadUrl("file:///" & File.DirInternal & "/page.html")
Erel B4X founder Staff member Licensed User Longtime User Aug 30, 2013 #7 It is better to write: Code: Copy web.LoadUrl("file://" & File.Combine(File.DirInternal, "page.html")) Upvote 0
It is better to write: Code: Copy web.LoadUrl("file://" & File.Combine(File.DirInternal, "page.html"))
S Sarah Member Licensed User Longtime User Aug 30, 2013 #8 OK, thanks for the advice - I will change to using that structure. Upvote 0
warwound Expert Licensed User Longtime User Aug 30, 2013 #9 Erel said: It is better to write: Code: Copy web.LoadUrl("file://" & File.Combine(File.DirInternal, "page.html")) Click to expand... Is that a typo or should there only be 2 slashes after file: instead of 3? Martin. Upvote 0
Erel said: It is better to write: Code: Copy web.LoadUrl("file://" & File.Combine(File.DirInternal, "page.html")) Click to expand... Is that a typo or should there only be 2 slashes after file: instead of 3? Martin.
S Sarah Member Licensed User Longtime User Aug 30, 2013 #10 Both 2 slashes & 3 slashes works in my tests. I haven't checked but I assume File.Combine returns a path starting with a slash, so that provides the third. Upvote 0
Both 2 slashes & 3 slashes works in my tests. I haven't checked but I assume File.Combine returns a path starting with a slash, so that provides the third.