Dylan
Dylan

Reputation: 9373

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?

Upvotes: 7

Views: 1801

Answers (1)

Blaise
Blaise

Reputation: 13479

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.

Upvotes: 3

Related Questions