-------------------------------------------------------------------------------------------
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<meta name="msapplication-tap-highlight" content="no" />
<!-- WARNING: for iOS 7, remove the width=device-width and height=device-height attributes. See https://issues.apache.org/jira/browse/CB-4323 -->
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=medium-dpi" />
<link rel="stylesheet" type="text/css" href="css/jquery.mobile-1.4.5.min.css" />
<title>Exit Testing</title>
</head>
<body>
<section data-role="page" id="pg1">
<a id="a_exit" href="#" class="ui-btn ui-btn-inline">離開</a>
</section> <!-- page pg1 -->
</body>
</html>
<script type="text/javascript" src="jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="jquery.mobile-1.4.5.min.js"></script>
<script>
// Wait for device API libraries to load
document.addEventListener("deviceready", onDeviceReady, false);
// device APIs are available
function onDeviceReady() {
//Exit APP
$("#a_exit").on("tap",function(){
navigator.app.exitApp();
});
}
</script>
以Phonegap編譯成APP後,實地測試的結果失敗,無法正確關閉APP。
原因是找不到navigator.app.exitApp()這個函數,因為沒有把js掛進來。
加上下列的語法,重新編譯後就可以正常離開了。
<script type="text/javascript" src="cordova.js"></script>