Phonegap sets the root directory for asset files

I had a few questions, but I canโ€™t find them old and without any solutions.

So, in my resource folder, I have the following tree:

- ressources - img - logo.png - css - style.css - process1 - page1.html - index.html 

My "index.html" when I turn on img / logo.png or css / style.css, everything works fine.

But for the same result in "page1.html" I have to use .. /img/logo.png and this is pretty annoying since I have many pages.

I found two ugly solutions:

  • Copy the "ressources" folder to each subfolder
  • Create a script that will change the entire root directory url for each os (file: /// android_asset / www / for android)
+6
source share
1 answer

Perhaps the solution is to use a base tag that allows you to set a default base for all your relatives. Therefore for android it will be:

 <base href="file:///android_asset/www/" target="_blank"> 

And all your links will be:

 <img src="img/logo.png"> 
+11
source

Source: https://habr.com/ru/post/950611/


All Articles