Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Phonegap: Set base href but still Include local JS/CSS/Images

Tags:

cordova

I am making remote ajax calls in my phonegap index.html file and the response is an html snippet including relative references to javascript, css and image files on the remote server. In order for the relative references to function properly I include a <base href="http://myserver.com" /> tag in my index.html file.

This works as expected.

However, I would like to also include local CSS/JS/Image files stored in the www directory of my Phonegap Application. As I set the base href to http://myserver.com I can no longer include them using relative URLs (e.g. <script src="phonegap.0.9.5.js"></script>).

My question is: How can I reference these files?

I am hoping that something like this will work (as I am still posting this question, it is not quite that simple): <script src="file:///www/phonegap.0.9.5.js"></script>

Thanks in advance!

like image 993
Jonas Fischer Avatar asked May 24 '11 14:05

Jonas Fischer


1 Answers

Local images I reference with

./assets/img/img.png

and then when I am getting something on the server I remove the starting dot. So when I am testing my application, I use an asset_path variable that either has the dot or not (in your case you could put the full URL).

like image 174
Luke Ollett Avatar answered Nov 19 '22 19:11

Luke Ollett