I have a multi-page news app built on Adobe CQ5 and using build.phonegap.com to compile. I can;t figure out how to reference cordova.js from all the HTML pages.
It's easy enough to use <script src="cordova.js"></script>
on index.html, but the app is structured such that each article is its own HTML file on different directories. I can't hardcode the JS reference since I need it to be <script src="../cordova.js"></script>
on one file and <script src="../../cordova.js"></script>
on another and so on, depending on the directory of the HTML. Not to mention the path to assets and cordova.js is also different per device.
in a nutshell the structure is roughly like this:
/www/index.html <-- referencing cordova.js through <script src="cordova.js"></script>
/www/cordova.js
/www/content/breaking-news.html <-- this page needs to reference cordova.js too
/www/content/breaking-news/breaking-news-title.html <-- this page needs to reference cordova.js too
...
etc
How should I handle this? Is single page app the only solution? I am not concerned about performance since I've set up a contentsync system which will fetch zipped delta updates over the air and apply it to the app.
Relative path, like ../cordova.js
or cordova.js
depends on the current location of the referencing resource, like index.html
or breaking-news.html
. You should rather use an absolute path: /cordova.js
. It'll always reference the script from the site root, regardless the current web page path.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.