Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

phonegap set the root directory for asset files

Tags:

cordova

I have seen few questions but I can't find they were old and without any solutions.

So I'n my asset folder I have the following tree:

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

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

But to have the same result in "page1.html" I must use ../img/logo.png and it's quite annoying since I have a lot of pages.

I have found two ugly solutions:

  • Copy the "ressources" folder in each subfolder
  • Create a script that will change all the url to the root directory for each os (file:///android_asset/www/ for android)
like image 983
Alexis Avatar asked Jul 30 '13 09:07

Alexis


1 Answers

Maybe a solution is to use the base tag witch allow you to set a default base to all yours relatives links. So for android it will be:

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

And all yours link will be:

<img src="img/logo.png">
like image 129
audisi_r Avatar answered Oct 07 '22 07:10

audisi_r