jQuery和PhoneGap - 包括一个HTML文件客户端与HTML或JS? [英] jQuery and PhoneGap - Include a HTML file clientside with HTML or JS?
问题描述
我通过使用PhoneGap和jQuery Mobile创建一个原生的Android应用程序。
I'm creating an native Android application by using PhoneGap and jQuery Mobile.
当我创建一个多页面的页面时,我不包括相同的导航栏时间。
所以我试图包括一个(s)html。但它不工作。
这是我试过这么远:
When I create a multipaged page, i don't to include the same navigationbar all the time. So I tried to include a (s)html. But it doesn't work. This is what i've tried this far:
<!--#include file="navigation.inc.html" -->
<!--#include virtual="navigation.inc.html" -->
<!--#include file="navigation.inc.shtml" -->
<!--#include virtual="navigation.inc.shtml" -->
此网页未放置在(网络)服务器上。
当navigation.inc.shtml不是服务器时,是否可以包含带有html或javascript的文件?
This page is not placed on a (web)server. When the navigation.inc.shtml is not a server, is it possible to include the file with html or javascript?
推荐答案
我遇到同样的问题。就我可以告诉,Android忽略服务器端包含。
I'm running into the same issue. As far as I can tell, Android ignores Server Side Includes.
我已经接近的答案与 load
。 answer
,但我采用略有不同的方法:
I've been getting close to the answer with load
based on this answer
but I'm taking a slightly different approach:
无论您需要包含一个外部文件:
Wherever you need to include an external file:
<div data-include="footer"></div>
然后,在我的(多页)index.html
Then, at the end of my ( multipage ) index.html
$('div[data-include]').each(function() {
$(this).load( $(this).attr('data-include') + '.html').trigger('create');
});
问题是它不能用于初始页面视图。任何后续网页看起来都很棒。
The problem is that it doesn't work for the initial page view. Any subsequent pages look great.
这篇关于jQuery和PhoneGap - 包括一个HTML文件客户端与HTML或JS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!