Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Phonegap: how to use absolute paths on both Android, iOS and browser?

I'm trying out Phonegap to develop for both Android and iOS using the same source.

I would like to use absolute paths like :

background-image: url(/graphics/test.png);

but this doesn't work on Android or iOS.

I found out that for Android I have to use something like :

background-image: url(file:///android_asset/www/graphics/test.png);

but of course this doesn't make sense in a browser (for testing the app) and on iOS.

The problem is that I'm using a framework that uses absolute paths all the time.

I tried setting a BASE tag but couldn't get it to work...

Is there any way to use the same absolute paths on all platforms?

like image 996
Dylan Avatar asked Apr 02 '12 00:04

Dylan


1 Answers

No, you cannot use absolute paths because they're different on all platforms, and there are no plugins or configuration to unify absolute paths.

It's best to try again solving this in the framework that you're using. We may be able to help you with that if you provide information about this framework.

Alternatively, you could serve your www dir from the web (<content src="http://example.org" /> in config.xml), but that means your app only works with an internet connection.

like image 143
Blaise Avatar answered Nov 14 '22 07:11

Blaise