【发布时间】:2013-09-03 11:56:41
【问题描述】:
在我的 PhoneGap android 应用程序中,在我的 Index.html 页面中的 OnDeviceReady() 方法中,我为后退按钮事件侦听器添加了以下函数。
document.addEventListener("backbutton", function(e) {
var sPath=window.location.pathname;
var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
if(sPage == "index.html"){
e.preventDefault();
// My action
return false;
} else {
return true;
}
}, false);
面临的问题:
在我的 HomePage(Index.html) 中,它工作正常。如果我按下返回按钮,它就会关闭。
但是在所有其他页面(Page1.html,Page2.html,Page3.html,Page4.html)中,我没有创建后退按钮事件侦听器,但是当我按下后退键时没有任何反应。
【问题讨论】:
-
你是如何从主页移动到另一个页面的?
-
来自按钮点击事件,使用代码“window.location = "page1.html";"
标签: javascript android jquery-mobile cordova