[英]using build.phonegap.com - how to reference cordova.js on pages other than index.html?
I have a multi-page news app built on Adobe CQ5 and using build.phonegap.com to compile. 我有一个基于Adobe CQ5构建并使用build.phonegap.com进行编译的多页新闻应用程序。 I can;t figure out how to reference cordova.js from all the HTML pages.
我无法弄清楚如何从所有HTML页面中引用cordova.js。
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. 在index.html上使用
<script src="cordova.js"></script>
很容易,但是应用程序的结构使得每篇文章在不同目录下都是自己的HTML文件。 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. 我无法对JS参考进行硬编码,因为我需要将其作为
<script src="../cordova.js"></script>
放在一个文件中,并将其作为<script src="../../cordova.js"></script>
,依此类推,具体取决于HTML目录。 Not to mention the path to assets and cordova.js is also different per device. 更不用说资产的获取路径,并且cordova.js在每个设备上也有所不同。
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.
我不担心性能,因为我已经设置了contentsync系统,该系统将通过空中获取压缩的增量更新并将其应用于应用程序。
Relative path, like ../cordova.js
or cordova.js
depends on the current location of the referencing resource, like index.html
or breaking-news.html
. 相对路径,例如
../cordova.js
或cordova.js
取决于引用资源的当前位置,例如index.html
或cordova.js
breaking-news.html
。 You should rather use an absolute path: /cordova.js
. 您应该使用绝对路径:
/cordova.js
。 It'll always reference the script from the site root, regardless the current web page path. 无论当前的网页路径如何,它将始终从站点根目录引用脚本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.