我有以下代码:
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
document.addEventListener("backbutton", onBackKeyDown, false);
}
function onBackKeyDown() {
if ($.mobile.activePage.attr("id") === "home") {
e.preventDefault();
navigator.app.exitApp(); //not working
}
}
正在输入我的onBackKeyDown()
函数,现在我收到了一系列奇怪的事件:
- 我的 if 条件从未输入过,即使我的条件
$.mobile.activePage.attr("id") === "home"
为真(在 weinre 服务器上测试) - navigator.app.exitApp 从不工作,这似乎发生在我的整个应用程序中,而不仅仅是这个功能。
- 后退按钮在我的整个应用程序中都没有响应。
知道为什么我会出现这种奇怪的行为吗?Phonegap 2.6、jquery mobile 1.3.0 并在 Android 2.3.7 上进行测试。