次のことを試してください。
<!DOCTYPE html>
<html>
<head>
<title>gaurish's Cordova Back Button Example</title>
<script type="text/javascript" charset="utf-8" src="cordova-2.0.0.js"></script>
<script type="text/javascript" charset="utf-8">
// Call onDeviceReady when Cordova is loaded.
//
// At this point, the document has loaded but cordova-2.0.0.js has not.
// When Cordova is loaded and talking with the native device,
// it will call the event `deviceready`.
//
function onLoad() {
document.addEventListener("deviceready", onDeviceReady, false);
}
// Cordova is loaded and it is now safe to call Cordova methods
//
function onDeviceReady() {
// Register the event listener
document.addEventListener("backbutton", onBackKeyDown, false);
}
// Handle the back button
//
function onBackKeyDown() {
}
</script>
</head>
<body onload="onLoad()">
</body>
</html>
今、これをテストするには
実行するコードを追加onBackKeyDown()
します。例
function onBackKeyDown() {
currentId = $.mobile.activePage.attr('id');
if(currentId == "#swipediv"){
$.mobile.changePage("#home", "slide", false, true);
}
else{
history.go(-1);
}
}
積み込みますcordova-2.0.0.js
- チェックアウトWP7PhoneGapバックボタンサポートの再検討
- ドキュメントを読む
それでも機能しない場合は、バグレポートを提出してください。