繁体   English   中英

通过使用phonegap android中的“后退”按钮从images.html返回index.html

[英]return to index.html from images.html by using phone back button in phonegap android

我正在使用android phonegap,我的应用程序有2个.html页面,(1)index.html使用jquery mobile有多个页面,我在index.html中有一个链接到(2)images.html,images.html很简单html页面,当我在images.html上时,我希望手机的后退按钮导航到具有ID#page2的index.html多个页面。 任何人都可以帮助我从(硬件)电话的后退按钮导航到index.html#page2,我已经有一个后退按钮代码,仅在index.html中可以正常工作,但是我如何使它可用从images.html返回index.html#page2,这是我的后退按钮代码,适用于我的index.html ..... // JavaScript文档

$("#page2").click(function(){
$.mobile.changePage("#page2");
});
document.addEventListener("deviceready", onDeviceReady, false);
// PhoneGap loaded

function onDeviceReady() {
console.log("PhoneGap Ready!");
// waiting for button
document.addEventListener("backbutton", handleBackButton, false);
}

// handle the back button
function handleBackButton() {
console.log("Back Button Pressed!");
if($.mobile.activePage.is('#page2')){
//e.preventDefault();
navigator.app.exitApp();
}
else {
navigator.app.backHistory();
}
}

尝试按照http://jquerymobile.com/demos/1.2.0/docs/pages/phonegap.html说明将$.mobile.phonegapNavigationEnabled = true放在mobileinit处理程序中。

尝试这个,

document.addEventListener("backbutton", onBackKeyDown, false);

function onBackKeyDown() {
    // Handle the back button
}

推荐这个

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM