PhoneGap / Cordova + JQueryMobile:是否应在所有页面中重复使用HEAD? [英] PhoneGap/Cordova + JQueryMobile: should HEAD be repeated in all pages?
问题描述
我正在此环境中迈出第一步,并试图找出最佳做法。我的应用程序包含几个HTML页面:
I'm doing my first steps in this environment and am trying to figure out the best practices. My app includes several HTML pages:
我应该将整个HEAD部分复制到所有HTML页面中吗,
还是只需要其中一些在最初的HTML页面中?
Should I duplicate the whole HEAD part into all the HTML pages,
Or maybe some of it is only required in the initial HTML page?
EXTRA
令我惊讶的是,我找不到最新的该应用程序的标准HTML标头的日期示例,因此,我也想分享一些知识。
To my wonder I couldn't find an up-to-date example of a standard HTML header for such app, so with my question I'm also doing a share of knowledge.
以下是我认为允许将JQM组合到PhoneGap中所需的标头:
Here is the header which, in my understanding, is required to allow the combination of JQM into PhoneGap:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<meta name="msapplication-tap-highlight" content="no" />
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width" />
<meta http-equiv="Content-Security-Policy" content="default-src 'self' gap://ready file://* *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; media-src *">
<title>JQM Test</title>
<link rel="stylesheet" href="css/jquery.mobile-1.4.5.min.css" />
<!-- extra css for my app: -->
<link rel="stylesheet" type="text/css" href="css/index.css" />
<!-- include JQ, enable PhoneGap events under JQM, then include JQM: -->
<script type="text/javascript" src="js/jquery-2.1.3.min.js"></script>
<script type="text/javascript">
$( document ).on( "mobileinit", function() {
$.support.cors = true;
$.mobile.allowCrossDomainPages = true;
$.mobile.phonegapNavigationEnabled = true;
});
</script>
<script type="text/javascript" src="js/jquery.mobile-1.4.5.min.js"></script>
</head>
为了完整起见,如果您想知道,cordova部分会出现在页面末尾:
Just for the completeness, in case you are wondering, the cordova part appears at the end of the page:
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/index.js"></script>
<script type="text/javascript">
app.initialize();
</script>
</body>
推荐答案
注意:如果此答案有误,请不要投票,而是添加一条注释来解释为什么它是错误的,以便我们所有人都可以学习。
Note: Please do not downvote if this answer is wrong, but instead add a note explaining why it is wrong, so that we can all learn.
没人回应,所以我将我的暂定答案
Nobody responded so I will put my tentative answer which I still need to verify.
在普通的网络应用中,必须重复标题,因为用户可以添加书签非初始页面,然后稍后再返回,因此每个页面都必须能够担当初始页面的角色。
In a normal web app, headers must be repeated because the user can bookmark a non-initial page, and get back to it later, so every page must be able to take the role of the initial page.
但是使用PhoneGap / Cordova,我们可以确保在启动时加载了特定页面,这样,由于页面是使用ajax加载的,因此我们可以跳过其他页面的包含部分。
However with PhoneGap/Cordova we can ensure a specific page is loaded on startup, and this way, because pages are loaded using ajax, we might be able to skip the include parts of the other pages.
这篇关于PhoneGap / Cordova + JQueryMobile:是否应在所有页面中重复使用HEAD?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!